2022-05-16 11:02:12 +00:00
|
|
|
name: build
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types: [opened, synchronize]
|
2023-07-26 12:48:05 +00:00
|
|
|
merge_group:
|
|
|
|
types: [checks_requested]
|
2023-09-05 09:58:56 +00:00
|
|
|
push:
|
|
|
|
# Always run on push to main. The build cache can only be reused
|
|
|
|
# if it was saved by a run from the repository's default branch.
|
|
|
|
# The run result will be identical to that from the merge queue
|
|
|
|
# because the commit is identical, yet we need to perform it to
|
|
|
|
# seed the build cache.
|
|
|
|
branches:
|
|
|
|
- main
|
2022-05-16 11:02:12 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
tests:
|
2022-11-28 10:34:25 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- macos-latest
|
|
|
|
- ubuntu-latest
|
|
|
|
- windows-latest
|
|
|
|
|
2022-05-16 11:02:12 +00:00
|
|
|
steps:
|
2022-09-07 09:55:59 +00:00
|
|
|
- name: Checkout repository and submodules
|
2023-09-05 08:27:18 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-05-16 11:02:12 +00:00
|
|
|
|
2022-09-08 09:21:00 +00:00
|
|
|
- name: Setup Go
|
2024-01-25 10:44:37 +00:00
|
|
|
uses: actions/setup-go@v5
|
2022-05-16 11:02:12 +00:00
|
|
|
with:
|
2024-10-31 12:42:14 +00:00
|
|
|
go-version: 1.23.2
|
2022-05-16 11:02:12 +00:00
|
|
|
|
2023-09-21 12:21:39 +00:00
|
|
|
- name: Setup Python
|
2024-03-18 12:48:50 +00:00
|
|
|
uses: actions/setup-python@v5
|
2023-09-21 12:21:39 +00:00
|
|
|
with:
|
2024-09-25 14:24:59 +00:00
|
|
|
python-version: '3.10'
|
2023-09-21 12:21:39 +00:00
|
|
|
|
2022-05-16 11:02:12 +00:00
|
|
|
- name: Set go env
|
|
|
|
run: |
|
|
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
2022-09-07 18:08:42 +00:00
|
|
|
go install gotest.tools/gotestsum@latest
|
2022-09-07 09:55:59 +00:00
|
|
|
go install honnef.co/go/tools/cmd/staticcheck@latest
|
2022-05-16 11:02:12 +00:00
|
|
|
|
|
|
|
- name: Pull external libraries
|
2023-07-26 09:02:17 +00:00
|
|
|
run: |
|
|
|
|
make vendor
|
2023-07-26 10:07:26 +00:00
|
|
|
pip3 install wheel
|
2022-05-16 11:02:12 +00:00
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: make test
|
2022-09-07 13:15:23 +00:00
|
|
|
|
2024-01-02 09:32:17 +00:00
|
|
|
- name: Publish test coverage
|
2024-03-18 12:48:59 +00:00
|
|
|
uses: codecov/codecov-action@v4
|
2024-01-02 09:32:17 +00:00
|
|
|
|
2022-09-07 13:15:23 +00:00
|
|
|
fmt:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2022-09-08 09:21:00 +00:00
|
|
|
- name: Checkout
|
2023-09-05 08:27:18 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-09-07 13:15:23 +00:00
|
|
|
|
2022-09-08 09:21:00 +00:00
|
|
|
- name: Setup Go
|
2024-01-25 10:44:37 +00:00
|
|
|
uses: actions/setup-go@v5
|
2022-09-07 13:15:23 +00:00
|
|
|
with:
|
2024-10-31 12:42:14 +00:00
|
|
|
go-version: 1.23.2
|
2022-09-07 13:15:23 +00:00
|
|
|
|
2022-09-08 09:21:00 +00:00
|
|
|
# No need to download cached dependencies when running gofmt.
|
|
|
|
cache: false
|
|
|
|
|
2023-10-27 15:43:44 +00:00
|
|
|
- name: Install goimports
|
2022-09-07 13:15:23 +00:00
|
|
|
run: |
|
2023-10-27 15:43:44 +00:00
|
|
|
go install golang.org/x/tools/cmd/goimports@latest
|
|
|
|
|
|
|
|
- name: Run make fmt
|
|
|
|
run: |
|
|
|
|
make fmt
|
2022-09-07 13:15:23 +00:00
|
|
|
|
2022-12-22 08:33:46 +00:00
|
|
|
- name: Run go mod tidy
|
|
|
|
run: |
|
|
|
|
go mod tidy
|
|
|
|
|
2022-09-07 13:15:23 +00:00
|
|
|
- name: Fail on differences
|
|
|
|
run: |
|
|
|
|
# Exit with status code 1 if there are differences (i.e. unformatted files)
|
|
|
|
git diff --exit-code
|
2024-03-28 11:25:36 +00:00
|
|
|
|
|
|
|
validate-bundle-schema:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v5
|
|
|
|
with:
|
2024-10-31 12:42:14 +00:00
|
|
|
go-version: 1.23.2
|
2024-03-28 11:25:36 +00:00
|
|
|
|
|
|
|
# Github repo: https://github.com/ajv-validator/ajv-cli
|
|
|
|
- name: Install ajv-cli
|
|
|
|
run: npm install -g ajv-cli@5.0.0
|
|
|
|
|
|
|
|
# Assert that the generated bundle schema is a valid JSON schema by using
|
2024-09-11 09:15:56 +00:00
|
|
|
# ajv-cli to validate it against bundle configuration files.
|
2024-03-28 11:25:36 +00:00
|
|
|
# By default the ajv-cli runs in strict mode which will fail if the schema
|
|
|
|
# itself is not valid. Strict mode is more strict than the JSON schema
|
|
|
|
# specification. See for details: https://ajv.js.org/options.html#strict-mode-options
|
|
|
|
- name: Validate bundle schema
|
|
|
|
run: |
|
|
|
|
go run main.go bundle schema > schema.json
|
2024-09-11 09:15:56 +00:00
|
|
|
|
|
|
|
for file in ./bundle/internal/schema/testdata/pass/*.yml; do
|
|
|
|
ajv test -s schema.json -d $file --valid
|
|
|
|
done
|
|
|
|
|
|
|
|
for file in ./bundle/internal/schema/testdata/fail/*.yml; do
|
|
|
|
ajv test -s schema.json -d $file --invalid
|
|
|
|
done
|