Skip to content

Commit

Permalink
ci: improve runtime of high usage CI workflows (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuasing authored Jul 5, 2024
1 parent 60a3489 commit 159fbc5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,32 @@ jobs:
cache: true
check-latest: true

- name: "Retrieve GOPATH"
id: retrieve
run: echo "GOPATH=$(go env GOPATH)" >> "$GITHUB_OUTPUT"

- name: "Setup GOPATH/bin cache"
uses: actions/cache@v4
with:
path: "${{ steps.retrieve.outputs.GOPATH }}/bin/"
key: "${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-${{ hashFiles('**/Makefile') }}"
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-${{ hashFiles('**/Makefile') }}
${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-
${{ runner.os }}-${{ runner.arch }}-gobin-
- name: "Download and verify dependencies"
id: deps
run: make deps
run: make GOCACHE="$(go env GOCACHE)" deps

- name: "make race"
run: make race
run: make GOCACHE="$(go env GOCACHE)" race

- name: "make"
if: (success() || failure()) && steps.deps.outcome == 'success'
env:
PGTESTURI: "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
HEMI_DOCKER_TESTS: "1"
run: |
make
make GOCACHE="$(go env GOCACHE)"
git diff --exit-code
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ jobs:
check-latest: true

- name: "Download and verify dependencies"
run: make deps
run: make GOCACHE="$(go env GOCACHE)" go-deps

- name: "Create binary archive for ${{ matrix.goos }}/${{ matrix.goarch }}"
env:
GOOS: "${{ matrix.goos }}"
GOARCH: "${{ matrix.goarch }}"
CGO_ENABLED: 0 # Disable CGO.
GOGC: off # Disable GC during build, faster but uses more RAM.
run: make archive
run: make GOCACHE="$(go env GOCACHE)" archive

- name: "Upload artifacts"
uses: actions/upload-artifact@v4
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cmds = \
popmd \
tbcd

.PHONY: all clean clean-dist deps $(cmds) build install lint lint-deps tidy race test vulncheck \
.PHONY: all clean clean-dist deps go-deps $(cmds) build install lint lint-deps tidy race test vulncheck \
vulncheck-deps dist archive sources checksums

all: lint tidy test build install
Expand All @@ -42,7 +42,9 @@ clean-dist:
clean-test:
rm -rf $(PROJECTPATH)/service/tbc/.testleveldb/

deps: lint-deps vulncheck-deps
deps: lint-deps vulncheck-deps go-deps

go-deps:
go mod download
go mod verify

Expand Down

0 comments on commit 159fbc5

Please sign in to comment.