ci: Update builds #384
Workflow file for this run
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
# Copyright 2022-2023 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@v4 | |
# 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@v4 | |
- 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@v4 | |
# 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: Export golang and golangci-lint versions | |
id: versions | |
run: | | |
echo "golangci-lint=$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_OUTPUT}" | |
echo "golang=$(devbox run -- go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>"${GITHUB_OUTPUT}" | |
- name: golangci-lint | |
uses: reviewdog/action-golangci-lint@v2 | |
with: | |
fail_on_error: true | |
reporter: github-pr-review | |
golangci_lint_version: v${{ steps.versions.outputs.golangci-lint }} | |
go_version: v${{ steps.versions.outputs.golang }} | |
generated: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# 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 | |
run: git diff --exit-code | |
lint-gha: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: actionlint | |
uses: reviewdog/action-actionlint@v1 | |
with: | |
fail_on_error: true | |
reporter: github-pr-review | |
lint-dockerfile: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: actionlint | |
uses: reviewdog/action-hadolint@v1 | |
with: | |
fail_on_error: true | |
reporter: github-pr-review | |
pre-commit: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# 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: 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,actionlint-system,hadolint | |
lint-test-helm: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install devbox | |
uses: jetpack-io/[email protected] | |
with: | |
enable-cache: true | |
- name: Run chart-testing (list-changed) | |
id: list-changed | |
run: | | |
changed="$(devbox run -- \ | |
ct list-changed --config charts/ct-config.yaml \ | |
)" | |
if [[ -n "$changed" ]]; then | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
fi | |
- if: steps.list-changed.outputs.changed == 'true' | |
name: Run chart-testing (lint) | |
run: | | |
devbox run -- \ | |
ct lint --config charts/ct-config.yaml | |
- if: steps.list-changed.outputs.changed == 'true' | |
name: Create kind cluster | |
run: | | |
devbox run -- \ | |
kind create cluster \ | |
--image=ghcr.io/mesosphere/kind-node:"$(devbox run -- kubectl version --output=json --client | devbox run -- gojq --raw-output .clientVersion.gitVersion)" \ | |
--name=chart-testing | |
env: | |
KUBECONFIG: ct-kind-kubeconfig | |
- if: steps.list-changed.outputs.changed == 'true' | |
name: Build Docker images | |
run: | | |
devbox run -- \ | |
make release-snapshot | |
- if: steps.list-changed.outputs.changed == 'true' | |
name: Sideload docker image | |
run: | | |
devbox run -- \ | |
kind load docker-image \ | |
--name chart-testing \ | |
"$(devbox run -- gojq -r '.[] | select(.type == "Docker Image" and .goos == "linux" and .goarch == "amd64").name' dist/artifacts.json)" | |
- if: steps.list-changed.outputs.changed == 'true' | |
name: Run chart-testing (install) | |
run: | | |
devbox run -- \ | |
ct install \ | |
--config charts/ct-config.yaml \ | |
--helm-extra-set-args "--set=image.tag=$(devbox run -- jq -r .version dist/metadata.json)" | |
env: | |
KUBECONFIG: ct-kind-kubeconfig | |
- if: steps.list-changed.outputs.changed == 'true' && always() | |
name: Delete chart-testing KinD cluster | |
run: | | |
devbox run -- \ | |
kind delete cluster --name chart-testing || true |