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 3 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
62 changes: 45 additions & 17 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 }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we throw in runner.arch too just in case we start using M1/M2 runners?

path: ./dist/devbox
retention-days: 7

typos:
name: Spell Check with Typos
if: github.ref != 'refs/heads/main'
Expand Down Expand Up @@ -85,15 +111,10 @@ jobs:
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]
with:
args: "--out-${NO_FUTURE}format colored-line-number --timeout=10m"
skip-cache: true
- run: go run ./cmd/devbox run lint
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the built artifact here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this, but I think longer term we can use the released devbox instead for speed since this is one of the first tests we want to see complete.


test:
needs: build-devbox
strategy:
matrix:
is-main:
Expand Down Expand Up @@ -133,8 +154,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 +197,18 @@ 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 }}
- run: chmod +x ./devbox
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it also needs to be added to the PATH.

- name: Install nix and devbox packages
run: |
export NIX_INSTALLER_NO_CHANNEL_ADD=1
Expand All @@ -198,18 +225,19 @@ 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 }}
- run: chmod +x ./devbox
- 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 && scripts/gofumpt.sh",
"test": "go test -race -cover ./...",
"update-examples": "devbox run build && go run testscripts/testrunner/updater/main.go"
}
Expand Down