-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimizations for main build workflow (#2534)
* Don't upload full dir from gomod step, make some steps parallel. Uploading/downloading the artifact takes longer than setting up deps in the test and build steps most of the time. Also remove double run of `go test` which left over from the time when test compilation was a separate command. * comments about gomod and go. files
- Loading branch information
Showing
2 changed files
with
46 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
name: Build and test | ||
on: | ||
push: | ||
branches: | ||
|
@@ -6,39 +7,58 @@ on: | |
branches: | ||
- master | ||
jobs: | ||
## Make sure go.mod and go.sum files are up-to-date with the code | ||
## TODO: make this fail if they're not up-to-date to inform the committer to udpate them | ||
gomod: | ||
runs-on: ubuntu-20.04 | ||
outputs: | ||
gomod: ${{ steps.gomod.outputs.gomod }} | ||
gosum: ${{ steps.gosum.outputs.gosum }} | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- run: make go-mod-tidy | ||
- run: make go-mod-download | ||
- run: tar -cvf ./src.tar.gz ./ # preserve file permissions | ||
- uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 | ||
with: | ||
name: src | ||
path: ./src.tar.gz | ||
- id: gomod | ||
run: | | ||
{ | ||
echo 'gomod<<FILE' | ||
cat go.mod | ||
echo | ||
echo FILE | ||
} >> "$GITHUB_OUTPUT" | ||
- id: gosum | ||
run: | | ||
{ | ||
echo 'gosum<<FILE' | ||
cat go.sum | ||
echo | ||
echo FILE | ||
} >> "$GITHUB_OUTPUT" | ||
lint: | ||
runs-on: ubuntu-20.04 | ||
needs: gomod | ||
steps: | ||
- uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0 | ||
with: | ||
name: src | ||
- run: tar -xvf ./src.tar.gz | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
## Sync go.mod and go.sum files from gomod job | ||
- name: restore_gomod | ||
run: echo "${{needs.gomod.outputs.gomod}}" > go.mod | ||
- name: restore_gosum | ||
run: echo "${{needs.gomod.outputs.gosum}}" > go.sum | ||
- run: make golint | ||
test: | ||
runs-on: ubuntu-20.04 | ||
needs: [gomod, lint] | ||
needs: gomod | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
testSuite: [test, integration-test, helm-test] | ||
steps: | ||
- uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0 | ||
with: | ||
name: src | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
## Sync go.mod and go.sum files from gomod job | ||
- name: restore_gomod | ||
run: echo "${{needs.gomod.outputs.gomod}}" > go.mod | ||
- name: restore_gosum | ||
run: echo "${{needs.gomod.outputs.gosum}}" > go.sum | ||
- uses: helm/[email protected] | ||
- run: tar -xvf ./src.tar.gz | ||
- run: | | ||
make install-csi-hostpath-driver | ||
make install-minio | ||
|
@@ -53,42 +73,38 @@ jobs: | |
- run: make ${{ matrix.testSuite }} | ||
build: | ||
runs-on: ubuntu-20.04 | ||
needs: [gomod, lint, test] | ||
needs: gomod | ||
strategy: | ||
matrix: | ||
bin: [controller, kanctl, kando] | ||
steps: | ||
- uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0 | ||
with: | ||
name: src | ||
- run: tar -xvf ./src.tar.gz | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
## Sync go.mod and go.sum files from gomod job | ||
- name: restore_gomod | ||
run: echo "${{needs.gomod.outputs.gomod}}" > go.mod | ||
- name: restore_gosum | ||
run: echo "${{needs.gomod.outputs.gosum}}" > go.sum | ||
- run: make build BIN=${{ matrix.bin }} GOBORING=true | ||
docs: | ||
runs-on: ubuntu-20.04 | ||
needs: gomod | ||
steps: | ||
- uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0 | ||
with: | ||
name: src | ||
- run: tar -xvf ./src.tar.gz | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- run: make docs | ||
release: | ||
runs-on: ubuntu-20.04 | ||
needs: [test, build] | ||
needs: [lint, test, build, docs] | ||
if: github.ref_name == 'master' || startsWith(github.ref, 'refs/tags') | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0 | ||
with: | ||
name: src | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- run: make go-mod-tidy | ||
- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- run: sudo rm -rf /usr/share/dotnet | ||
- run: sudo rm -rf "$AGENT_TOOLSDIRECTORY" | ||
- run: tar -xvf ./src.tar.gz | ||
- run: make release-snapshot | ||
- run: ./build/push_images.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters