mirror of
https://github.com/goreleaser/nfpm.git
synced 2026-06-19 08:05:04 +00:00
ci: updating build scripts (#877)
* ci: updating build scripts * test: fixing cleanup, missing file * ci: dependabot auto-merge only if everything passes
This commit is contained in:
committed by
GitHub
parent
afeac6e542
commit
07dfc73d48
+65
-11
@@ -1,5 +1,9 @@
|
||||
name: build
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.head_ref || github.ref_name }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
@@ -11,7 +15,7 @@ on:
|
||||
- "**/*.go"
|
||||
- "Taskfile.yml"
|
||||
- "Dockerfile"
|
||||
- ".github/workflows/build.yml"
|
||||
- ".github/workflows/*.yml"
|
||||
- "testdata/**"
|
||||
- ".goreleaser.yml"
|
||||
pull_request:
|
||||
@@ -20,7 +24,7 @@ on:
|
||||
- "**/*.go"
|
||||
- "Taskfile.yml"
|
||||
- "Dockerfile"
|
||||
- ".github/workflows/build.yml"
|
||||
- ".github/workflows/*.yml"
|
||||
- "testdata/**"
|
||||
- ".goreleaser.yml"
|
||||
|
||||
@@ -42,7 +46,7 @@ jobs:
|
||||
unit-tests:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -52,11 +56,8 @@ jobs:
|
||||
- uses: arduino/setup-task@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: setup-tparse
|
||||
run: go install github.com/mfridman/tparse@latest
|
||||
- run: task setup
|
||||
- name: test
|
||||
run: ./scripts/test.sh test ${{ matrix.os }}
|
||||
- run: task test
|
||||
- uses: codecov/codecov-action@v4
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
with:
|
||||
@@ -82,9 +83,62 @@ jobs:
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- run: task setup
|
||||
- name: setup-tparse
|
||||
run: go install github.com/mfridman/tparse@latest
|
||||
- name: acceptance
|
||||
run: ./scripts/test.sh acceptance ubuntu-latest
|
||||
- run: task acceptance
|
||||
env:
|
||||
TEST_PATTERN: "/${{ matrix.pkgFormat }}/${{ matrix.pkgPlatform }}/"
|
||||
windows-build-pkgs:
|
||||
needs: [unit-tests]
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
- uses: arduino/setup-task@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
|
||||
with:
|
||||
path: dist/
|
||||
key: ${{ env.sha_short }}
|
||||
enableCrossOsArchive: true
|
||||
- run: task acceptance:windows:package
|
||||
install-windows-pkgs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [windows-build-pkgs]
|
||||
steps:
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: arduino/setup-task@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
|
||||
with:
|
||||
path: dist/
|
||||
key: ${{ env.sha_short }}
|
||||
enableCrossOsArchive: true
|
||||
- run: task acceptance:windows:install
|
||||
dependabot:
|
||||
needs: [unit-tests, acceptance-tests, install-windows-pkgs]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
|
||||
steps:
|
||||
- id: metadata
|
||||
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0
|
||||
with:
|
||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
- run: |
|
||||
gh pr review --approve "$PR_URL"
|
||||
gh pr merge --squash --auto "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{github.event.pull_request.html_url}}
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
name: windows
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "go.*"
|
||||
- "**/*.go"
|
||||
- "Taskfile.yml"
|
||||
- ".github/workflows/windows.yml"
|
||||
pull_request:
|
||||
paths:
|
||||
- "go.*"
|
||||
- "**/*.go"
|
||||
- "Taskfile.yml"
|
||||
- ".github/workflows/windows.yml"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
- uses: arduino/setup-task@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: setup-tparse
|
||||
run: go install github.com/mfridman/tparse@latest
|
||||
- run: task setup
|
||||
- name: test
|
||||
shell: bash
|
||||
run: ./scripts/test.sh test windows-latest
|
||||
build-pkgs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
- uses: arduino/setup-task@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
|
||||
with:
|
||||
path: dist/
|
||||
key: ${{ env.sha_short }}
|
||||
enableCrossOsArchive: true
|
||||
- run: task acceptance:windows:package
|
||||
install-pkgs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-pkgs]
|
||||
steps:
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: arduino/setup-task@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
|
||||
with:
|
||||
path: dist/
|
||||
key: ${{ env.sha_short }}
|
||||
enableCrossOsArchive: true
|
||||
- run: task acceptance:windows:install
|
||||
+1
-1
@@ -112,7 +112,7 @@ func TestUpgrade(t *testing.T) {
|
||||
|
||||
f, err := os.Create(target)
|
||||
require.NoError(t, err)
|
||||
defer f.Close()
|
||||
t.Cleanup(func() { require.NoError(t, f.Close()) })
|
||||
info.Target = target
|
||||
require.NoError(t, pkg.Package(nfpm.WithDefaults(info), f))
|
||||
|
||||
|
||||
+2
-1
@@ -114,7 +114,7 @@ func TestCreateBuilderData(t *testing.T) {
|
||||
|
||||
require.NoError(t, builderData(tw))
|
||||
|
||||
require.Equal(t, 13824, buf.Len(), buf.String())
|
||||
require.Equal(t, 15872, buf.Len(), buf.String())
|
||||
}
|
||||
|
||||
func TestCombineToApk(t *testing.T) {
|
||||
@@ -136,6 +136,7 @@ func TestDefaultWithArch(t *testing.T) {
|
||||
"usr/bin/fake": "f46cece3eeb7d9ed5cb244d902775427be71492d",
|
||||
"etc/fake/fake.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
|
||||
"etc/fake/fake2.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
|
||||
"etc/fake/fake3.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
|
||||
}
|
||||
for _, arch := range []string{"386", "amd64"} {
|
||||
arch := arch
|
||||
|
||||
@@ -215,6 +215,7 @@ func createFilesInTar(info *nfpm.Info, tw *tar.Writer) ([]MtreeEntry, int64, err
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
defer src.Close() // nolint: errcheck
|
||||
|
||||
header := &tar.Header{
|
||||
Name: content.Destination,
|
||||
@@ -577,6 +578,7 @@ func writeScripts(w io.Writer, scripts map[string]string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fl.Close() //nolint: errcheck
|
||||
|
||||
_, err = io.Copy(w, fl)
|
||||
if err != nil {
|
||||
|
||||
+1
-5
@@ -658,11 +658,7 @@ func newFileInsideTar(out *tar.Writer, name string, content []byte, modtime time
|
||||
}
|
||||
|
||||
func newFilePathInsideTar(out *tar.Writer, path, dest string, mode int64, modtime time.Time) error {
|
||||
file, err := os.Open(path) //nolint:gosec
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content, err := io.ReadAll(file)
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o pipefail && TEST_OPTIONS="-json" task $1 | tee output.json | tparse -follow
|
||||
success=$?
|
||||
|
||||
if [ "$2" = "ubuntu-latest" ]; then
|
||||
set -e
|
||||
NO_COLOR=1 tparse -format markdown -slow 10 -file output.json > $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
exit $success
|
||||
Reference in New Issue
Block a user