Skip to content

Commit 07dfc73

Browse files
authored
ci: updating build scripts (#877)
* ci: updating build scripts * test: fixing cleanup, missing file * ci: dependabot auto-merge only if everything passes
1 parent afeac6e commit 07dfc73

File tree

7 files changed

+71
-106
lines changed

7 files changed

+71
-106
lines changed

.github/workflows/build.yml

+65-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: build
22

3+
concurrency:
4+
group: ${{ github.head_ref || github.ref_name }}
5+
cancel-in-progress: true
6+
37
on:
48
push:
59
tags:
@@ -11,7 +15,7 @@ on:
1115
- "**/*.go"
1216
- "Taskfile.yml"
1317
- "Dockerfile"
14-
- ".github/workflows/build.yml"
18+
- ".github/workflows/*.yml"
1519
- "testdata/**"
1620
- ".goreleaser.yml"
1721
pull_request:
@@ -20,7 +24,7 @@ on:
2024
- "**/*.go"
2125
- "Taskfile.yml"
2226
- "Dockerfile"
23-
- ".github/workflows/build.yml"
27+
- ".github/workflows/*.yml"
2428
- "testdata/**"
2529
- ".goreleaser.yml"
2630

@@ -42,7 +46,7 @@ jobs:
4246
unit-tests:
4347
strategy:
4448
matrix:
45-
os: [ubuntu-latest, macos-latest]
49+
os: [ubuntu-latest, macos-latest, windows-latest]
4650
runs-on: ${{ matrix.os }}
4751
steps:
4852
- uses: actions/checkout@v4
@@ -52,11 +56,8 @@ jobs:
5256
- uses: arduino/setup-task@v2
5357
with:
5458
repo-token: ${{ secrets.GITHUB_TOKEN }}
55-
- name: setup-tparse
56-
run: go install github.com/mfridman/tparse@latest
5759
- run: task setup
58-
- name: test
59-
run: ./scripts/test.sh test ${{ matrix.os }}
60+
- run: task test
6061
- uses: codecov/codecov-action@v4
6162
if: matrix.os == 'ubuntu-latest'
6263
with:
@@ -82,9 +83,62 @@ jobs:
8283
- uses: docker/setup-qemu-action@v3
8384
- uses: docker/setup-buildx-action@v3
8485
- run: task setup
85-
- name: setup-tparse
86-
run: go install github.com/mfridman/tparse@latest
87-
- name: acceptance
88-
run: ./scripts/test.sh acceptance ubuntu-latest
86+
- run: task acceptance
8987
env:
9088
TEST_PATTERN: "/${{ matrix.pkgFormat }}/${{ matrix.pkgPlatform }}/"
89+
windows-build-pkgs:
90+
needs: [unit-tests]
91+
runs-on: windows-latest
92+
steps:
93+
- uses: actions/checkout@v4
94+
- uses: actions/setup-go@v5
95+
with:
96+
go-version: stable
97+
- uses: arduino/setup-task@v2
98+
with:
99+
repo-token: ${{ secrets.GITHUB_TOKEN }}
100+
- shell: bash
101+
run: |
102+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
103+
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
104+
with:
105+
path: dist/
106+
key: ${{ env.sha_short }}
107+
enableCrossOsArchive: true
108+
- run: task acceptance:windows:package
109+
install-windows-pkgs:
110+
runs-on: ubuntu-latest
111+
needs: [windows-build-pkgs]
112+
steps:
113+
- uses: docker/setup-qemu-action@v3
114+
- uses: actions/checkout@v4
115+
- uses: arduino/setup-task@v2
116+
with:
117+
repo-token: ${{ secrets.GITHUB_TOKEN }}
118+
- shell: bash
119+
run: |
120+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
121+
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
122+
with:
123+
path: dist/
124+
key: ${{ env.sha_short }}
125+
enableCrossOsArchive: true
126+
- run: task acceptance:windows:install
127+
dependabot:
128+
needs: [unit-tests, acceptance-tests, install-windows-pkgs]
129+
runs-on: ubuntu-latest
130+
permissions:
131+
pull-requests: write
132+
contents: write
133+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
134+
steps:
135+
- id: metadata
136+
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0
137+
with:
138+
github-token: "${{ secrets.GITHUB_TOKEN }}"
139+
- run: |
140+
gh pr review --approve "$PR_URL"
141+
gh pr merge --squash --auto "$PR_URL"
142+
env:
143+
PR_URL: ${{github.event.pull_request.html_url}}
144+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/windows.yml

-77
This file was deleted.

acceptance_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func TestUpgrade(t *testing.T) {
112112

113113
f, err := os.Create(target)
114114
require.NoError(t, err)
115-
defer f.Close()
115+
t.Cleanup(func() { require.NoError(t, f.Close()) })
116116
info.Target = target
117117
require.NoError(t, pkg.Package(nfpm.WithDefaults(info), f))
118118

apk/apk_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func TestCreateBuilderData(t *testing.T) {
114114

115115
require.NoError(t, builderData(tw))
116116

117-
require.Equal(t, 13824, buf.Len(), buf.String())
117+
require.Equal(t, 15872, buf.Len(), buf.String())
118118
}
119119

120120
func TestCombineToApk(t *testing.T) {
@@ -136,6 +136,7 @@ func TestDefaultWithArch(t *testing.T) {
136136
"usr/bin/fake": "f46cece3eeb7d9ed5cb244d902775427be71492d",
137137
"etc/fake/fake.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
138138
"etc/fake/fake2.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
139+
"etc/fake/fake3.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
139140
}
140141
for _, arch := range []string{"386", "amd64"} {
141142
arch := arch

arch/arch.go

+2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func createFilesInTar(info *nfpm.Info, tw *tar.Writer) ([]MtreeEntry, int64, err
215215
if err != nil {
216216
return nil, 0, err
217217
}
218+
defer src.Close() // nolint: errcheck
218219

219220
header := &tar.Header{
220221
Name: content.Destination,
@@ -577,6 +578,7 @@ func writeScripts(w io.Writer, scripts map[string]string) error {
577578
if err != nil {
578579
return err
579580
}
581+
defer fl.Close() //nolint: errcheck
580582

581583
_, err = io.Copy(w, fl)
582584
if err != nil {

deb/deb.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,7 @@ func newFileInsideTar(out *tar.Writer, name string, content []byte, modtime time
658658
}
659659

660660
func newFilePathInsideTar(out *tar.Writer, path, dest string, mode int64, modtime time.Time) error {
661-
file, err := os.Open(path) //nolint:gosec
662-
if err != nil {
663-
return err
664-
}
665-
content, err := io.ReadAll(file)
661+
content, err := os.ReadFile(path)
666662
if err != nil {
667663
return err
668664
}

scripts/test.sh

-11
This file was deleted.

0 commit comments

Comments
 (0)