From 016280aadbb5ecaa09f81f4e861e1526952b73d3 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 11 Jul 2023 01:13:57 +0000 Subject: [PATCH 1/7] build: pkg on windows, install on linux Signed-off-by: Carlos Alexandro Becker --- .github/workflows/build.yml | 60 +++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb2575cf..266f001c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,20 +7,20 @@ on: branches: - main paths: - - 'go.*' - - '**/*.go' - - 'Taskfile.yml' - - 'Dockerfile' - - '.github/workflows/build.yml' - - 'testdata/**' + - "go.*" + - "**/*.go" + - "Taskfile.yml" + - "Dockerfile" + - ".github/workflows/build.yml" + - "testdata/**" pull_request: paths: - - 'go.*' - - '**/*.go' - - 'Taskfile.yml' - - 'Dockerfile' - - '.github/workflows/build.yml' - - 'testdata/' + - "go.*" + - "**/*.go" + - "Taskfile.yml" + - "Dockerfile" + - ".github/workflows/build.yml" + - "testdata/" permissions: contents: read @@ -36,11 +36,11 @@ jobs: uses: caarlos0/meta/.github/workflows/ruleguard.yml@main with: go-version: stable - args: '-disable largeloopcopy' + args: "-disable largeloopcopy" unit-tests: strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -60,11 +60,39 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.txt + build-pkgs-on-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: stable + - run: mkdir ./tmp + - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p deb -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p rpm -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p apk -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p archlinux -t ./tmp/ + - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: ./tmp/ + key: ${{ github.ref }} + install-pkgs-built-on-windows: + runs-on: ubuntu-latest + needs: [build-pkgs-on-windows] + steps: + - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: ./tmp/ + key: ${{ github.ref }} + - uses: docker/setup-qemu-action@v2 + - run: docker run --rm --workdir /tmp -v $PWD/./tmp:/tmp fedora rpm -ivh *.rpm + - run: docker run --rm --workdir /tmp -v $PWD/./tmp:/tmp ubuntu dpkg -i *.deb + acceptance-tests: strategy: matrix: - pkgFormat: [ deb, rpm, apk, archlinux ] - pkgPlatform: [ amd64, arm64, 386, ppc64le, armv6, armv7, s390x ] + pkgFormat: [deb, rpm, apk, archlinux] + pkgPlatform: [amd64, arm64, 386, ppc64le, armv6, armv7, s390x] runs-on: ubuntu-latest env: DOCKER_CLI_EXPERIMENTAL: "enabled" From 159c8f7826b1984be245bfe6fe33dc2079334ea2 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 11 Jul 2023 01:20:42 +0000 Subject: [PATCH 2/7] fix: paths --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 266f001c..edd20fbb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,10 +68,10 @@ jobs: with: go-version: stable - run: mkdir ./tmp - - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p deb -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p rpm -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p apk -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/core.simple.yml -p archlinux -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p deb -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p rpm -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p apk -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p archlinux -t ./tmp/ - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 with: path: ./tmp/ From 053e87542782511b3c34973333b982ddd1836c60 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 11 Jul 2023 01:32:53 +0000 Subject: [PATCH 3/7] fix: path again Signed-off-by: Carlos Alexandro Becker --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index edd20fbb..5da3a6ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,10 +68,10 @@ jobs: with: go-version: stable - run: mkdir ./tmp - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p deb -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p rpm -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p apk -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yml -p archlinux -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p deb -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p rpm -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p apk -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p archlinux -t ./tmp/ - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 with: path: ./tmp/ From 5c38f97f8a3f4a5625ae5b8d0b9ca450db14adeb Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 11 Jul 2023 01:40:22 +0000 Subject: [PATCH 4/7] fix: build --- .github/workflows/build.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5da3a6ff..995fa016 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,24 +67,27 @@ jobs: - uses: actions/setup-go@v4 with: go-version: stable - - run: mkdir ./tmp + - run: mkdir dist + - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: dist/ + key: ${{ github.ref }} + enableCrossOsArchive: true - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p deb -t ./tmp/ - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p rpm -t ./tmp/ - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p apk -t ./tmp/ - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p archlinux -t ./tmp/ - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 - with: - path: ./tmp/ - key: ${{ github.ref }} install-pkgs-built-on-windows: runs-on: ubuntu-latest needs: [build-pkgs-on-windows] steps: + - uses: docker/setup-qemu-action@v2 - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 with: - path: ./tmp/ + path: dist/ key: ${{ github.ref }} - - uses: docker/setup-qemu-action@v2 + enableCrossOsArchive: true + - run: ls -lha dist - run: docker run --rm --workdir /tmp -v $PWD/./tmp:/tmp fedora rpm -ivh *.rpm - run: docker run --rm --workdir /tmp -v $PWD/./tmp:/tmp ubuntu dpkg -i *.deb From 0f98a23ddb4513f572af97f9252b707616ee9a94 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 11 Jul 2023 01:44:47 +0000 Subject: [PATCH 5/7] fix: build --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 995fa016..2335dc3e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,10 +73,10 @@ jobs: path: dist/ key: ${{ github.ref }} enableCrossOsArchive: true - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p deb -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p rpm -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p apk -t ./tmp/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p archlinux -t ./tmp/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p deb -t ./dist/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p rpm -t ./dist/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p apk -t ./dist/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p archlinux -t ./dist/ install-pkgs-built-on-windows: runs-on: ubuntu-latest needs: [build-pkgs-on-windows] @@ -88,8 +88,8 @@ jobs: key: ${{ github.ref }} enableCrossOsArchive: true - run: ls -lha dist - - run: docker run --rm --workdir /tmp -v $PWD/./tmp:/tmp fedora rpm -ivh *.rpm - - run: docker run --rm --workdir /tmp -v $PWD/./tmp:/tmp ubuntu dpkg -i *.deb + - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp fedora rpm -ivh *.rpm + - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp ubuntu dpkg -i *.deb acceptance-tests: strategy: From cf8b571067ef6a3ca449d8c5cb00a1753cb30299 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 11 Jul 2023 01:58:34 +0000 Subject: [PATCH 6/7] fix: full test --- .github/workflows/build.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2335dc3e..e17595d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,10 +73,10 @@ jobs: path: dist/ key: ${{ github.ref }} enableCrossOsArchive: true - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p deb -t ./dist/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p rpm -t ./dist/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p apk -t ./dist/ - - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p archlinux -t ./dist/ + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p deb -t ./dist/foo.deb + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p rpm -t ./dist/foo.rpm + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p apk -t ./dist/foo.apk + - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p archlinux -t ./dist/foo.pkg.tar.zst install-pkgs-built-on-windows: runs-on: ubuntu-latest needs: [build-pkgs-on-windows] @@ -88,9 +88,10 @@ jobs: key: ${{ github.ref }} enableCrossOsArchive: true - run: ls -lha dist - - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp fedora rpm -ivh *.rpm - - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp ubuntu dpkg -i *.deb - + - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp fedora rpm -ivh foo.rpm + - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp ubuntu dpkg -i foo.deb + - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp archlinux pacman --noconfirm -U foo.pkg.tar.zst + - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp alpine apk add --allow-untrusted foo.apk acceptance-tests: strategy: matrix: From 29dc309e88d1fbc6058adc26d5edb349836d017a Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 11 Jul 2023 02:13:51 +0000 Subject: [PATCH 7/7] fix: use sha_short as cache key --- .github/workflows/build.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e17595d6..7a443c9f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,10 +68,13 @@ jobs: with: go-version: stable - run: mkdir dist + - shell: bash + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 with: path: dist/ - key: ${{ github.ref }} + key: ${{ env.sha_short }} enableCrossOsArchive: true - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p deb -t ./dist/foo.deb - run: go run ./cmd/nfpm/... pkg -f ./testdata/acceptance/core.complex.yaml -p rpm -t ./dist/foo.rpm @@ -82,10 +85,14 @@ jobs: needs: [build-pkgs-on-windows] steps: - uses: docker/setup-qemu-action@v2 + - uses: actions/checkout@v3 + - shell: bash + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 with: path: dist/ - key: ${{ github.ref }} + key: ${{ env.sha_short }} enableCrossOsArchive: true - run: ls -lha dist - run: docker run --rm --workdir /tmp -v $PWD/dist:/tmp fedora rpm -ivh foo.rpm