Skip to content

[cicd] Unify lint, add caching #1549

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

Merged
merged 8 commits into from
Oct 12, 2023
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
80 changes: 62 additions & 18 deletions .github/workflows/cli-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@ env:
DEVBOX_DEBUG: 1

jobs:
build-devbox:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be faster to build all platforms on a single machine and set GOOS/GOARCH?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a bit slower no? In this case they can run in parallel?

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
- name: Mount golang cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg
key: go-devbox-build-${{ runner.os }}-${{ hashFiles('go.sum') }}
- name: Build devbox
run: go build -o dist/devbox ./cmd/devbox
- name: Upload devbox artifact
uses: actions/upload-artifact@v3
with:
name: devbox-${{ runner.os }}-${{ runner.arch }}
path: ./dist/devbox
retention-days: 7

typos:
name: Spell Check with Typos
if: github.ref != 'refs/heads/main'
Expand All @@ -55,6 +81,7 @@ jobs:
- uses: crate-ci/[email protected]

golangci-lint:
needs: build-devbox
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
Expand All @@ -70,6 +97,7 @@ jobs:
cache: false

# This can be reanabled once released version supports runx
# and we can remove needs: build-devbox
# - name: Install devbox
# uses: jetpack-io/[email protected]
# with:
Expand All @@ -84,16 +112,19 @@ jobs:
~/go/pkg
key: go-${{ runner.os }}-${{ hashFiles('go.sum') }}

# Use main devbox for now to ensure it supports runx
- run: go run ./cmd/devbox run fmt

- name: golangci-lint
uses: golangci/[email protected]
- name: Download devbox
uses: actions/download-artifact@v3
with:
args: "--out-${NO_FUTURE}format colored-line-number --timeout=10m"
skip-cache: true
name: devbox-${{ runner.os }}-${{ runner.arch }}
- name: Add devbox to path
run: |
chmod +x ./devbox
sudo mv ./devbox /usr/local/bin/

- run: devbox run lint

test:
needs: build-devbox
strategy:
matrix:
is-main:
Expand All @@ -117,7 +148,7 @@ jobs:
os: macos-latest

runs-on: ${{ matrix.os }}
timeout-minutes: ${{ (github.ref == 'refs/heads/main' || inputs.run-mac-tests) && 37 || 25 }}
timeout-minutes: 37
steps:
- name: Maximize build disk space
uses: easimon/maximize-build-space@v8
Expand All @@ -133,8 +164,13 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
- name: Build devbox
run: go install ./cmd/devbox
- name: Mount golang cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg
key: go-devbox-tests-${{ runner.os }}-${{ hashFiles('go.sum') }}
- name: Install additional shells (dash, zsh)
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
Expand Down Expand Up @@ -171,17 +207,21 @@ jobs:
go test -v -timeout $DEVBOX_GOLANG_TEST_TIMEOUT ./...

auto-nix-install: # ensure Devbox installs nix and works properly after installation.
needs: build-devbox
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- name: Download devbox
uses: actions/download-artifact@v3
with:
go-version-file: ./go.mod
- name: Build devbox
run: go install ./cmd/devbox
name: devbox-${{ runner.os }}-${{ runner.arch }}
- name: Add devbox to path
run: |
chmod +x ./devbox
sudo mv ./devbox /usr/local/bin/
- name: Install nix and devbox packages
run: |
export NIX_INSTALLER_NO_CHANNEL_ADD=1
Expand All @@ -198,18 +238,22 @@ jobs:
# Run a sanity test to make sure Devbox can install and remove packages with
# the last 3 Nix releases.
test-nix-versions:
needs: build-devbox
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
nix-version: [2.15.1, 2.16.1, 2.17.0, 2.18.0]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- name: Download devbox
uses: actions/download-artifact@v3
with:
go-version-file: ./go.mod
- name: Build devbox
run: go install ./cmd/devbox
name: devbox-${{ runner.os }}-${{ runner.arch }}
- name: Add devbox to path
run: |
chmod +x ./devbox
sudo mv ./devbox /usr/local/bin/
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
with:
Expand Down
3 changes: 1 addition & 2 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"GOOS=linux GOARCH=arm64 go build -o dist/devbox-linux-arm64 ./cmd/devbox"
],
"code": "code .",
"fmt": "scripts/gofumpt.sh",
"lint": "golangci-lint run",
"lint": "golangci-lint run --timeout 5m && scripts/gofumpt.sh",
"test": "go test -race -cover ./...",
"update-examples": "devbox run build && go run testscripts/testrunner/updater/main.go"
}
Expand Down