Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: updating build scripts #877

Merged
merged 5 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 65 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: build

concurrency:
group: ${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
push:
tags:
Expand All @@ -11,7 +15,7 @@ on:
- "**/*.go"
- "Taskfile.yml"
- "Dockerfile"
- ".github/workflows/build.yml"
- ".github/workflows/*.yml"
- "testdata/**"
- ".goreleaser.yml"
pull_request:
Expand All @@ -20,7 +24,7 @@ on:
- "**/*.go"
- "Taskfile.yml"
- "Dockerfile"
- ".github/workflows/build.yml"
- ".github/workflows/*.yml"
- "testdata/**"
- ".goreleaser.yml"

Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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}}
77 changes: 0 additions & 77 deletions .github/workflows/windows.yml

This file was deleted.

2 changes: 1 addition & 1 deletion acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
3 changes: 2 additions & 1 deletion apk/apk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 1 addition & 5 deletions deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 0 additions & 11 deletions scripts/test.sh

This file was deleted.

Loading