Skip to content

build: Use devbox instead of asdf #334

build: Use devbox instead of asdf

build: Use devbox instead of asdf #334

Workflow file for this run

# Copyright 2022 D2iQ, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: checks
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
permissions:
contents: read
pull-requests: write
jobs:
unit-test:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/[email protected]
- name: Run unit tests
run: devbox run -- make test
- name: Annotate tests
if: always()
uses: guyarb/[email protected]
with:
test-results: test.json
e2e-test:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Check e2e tests exist
id: check_e2e_files
uses: andstor/file-existence-action@v2
with:
files: "test/e2e/**/*.go"
# Setup github authentication to ensure Github's rate limits are not hit.
- if: steps.check_e2e_files.outputs.files_exists == 'true'
name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- if: steps.check_e2e_files.outputs.files_exists == 'true'
name: Install devbox
uses: jetpack-io/[email protected]
- if: steps.check_e2e_files.outputs.files_exists == 'true'
name: Run e2e tests
run: devbox run -- make e2e-test
lint:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/[email protected]
- name: Collect tool versions
run: |
echo GO_VERSION="$(devbox run -- go version | cut -d' ' -f 3 | grep -o '[0-9.]\+')" >>"${GITHUB_ENV}"
echo GOLANGCI_LINT_VERSION="$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_ENV}"
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
reporter: github-pr-review
go_version: ${{ env.GO_VERSION }}
golangci_lint_version: v${{ env.GOLANGCI_LINT_VERSION }}
generated:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/[email protected]
- name: Check generated files
run: devbox run -- make go-generate
- name: Verify no changed files
uses: tj-actions/verify-changed-files@v16
id: verify-changed-files
- name: Fail if files have changed
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}"
exit 1
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
# Setup github authentication to ensure Github's rate limits are not hit.
- name: Configure nix GitHub access-tokens
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf
- name: Install devbox
uses: jetpack-io/[email protected]
- uses: actions/setup-go@v4
with:
go-version: ${{ fromJson(steps.versions.outputs.tools).golang }}
check-latest: false
cache: true
- name: Set up pre-commit cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: devbox run -- make pre-commit
env:
SKIP: no-commit-to-branch,golangci-lint