feat: fetch package catalog from server, unify snapshot format, add c… #160
This file contains hidden or 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
| name: Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| repository_dispatch: | |
| types: [contract-updated] | |
| workflow_dispatch: | |
| inputs: | |
| run_destructive: | |
| description: 'Run destructive (real install) tests' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| test: | |
| name: test | |
| runs-on: macos-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: Vet | |
| run: go vet ./... | |
| - name: Run all tests | |
| run: make test-all | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run destructive tests | |
| if: ${{ inputs.run_destructive == true }} | |
| run: make test-destructive | |
| - name: Contract schema validation | |
| run: | | |
| git clone --depth 1 https://github.com/openbootdotdev/openboot-contract.git /tmp/contract | |
| pip3 install jsonschema | |
| python3 -c " | |
| import json, jsonschema, sys | |
| checks = [ | |
| ('/tmp/contract/schemas/remote-config.json', '/tmp/contract/fixtures/config-v1.json'), | |
| ('/tmp/contract/schemas/snapshot.json', '/tmp/contract/fixtures/snapshot-v1.json'), | |
| ] | |
| failed = 0 | |
| for schema_path, fixture_path in checks: | |
| schema = json.load(open(schema_path)) | |
| data = json.load(open(fixture_path)) | |
| try: | |
| jsonschema.validate(data, schema) | |
| print(f' ✓ {fixture_path.split(\"/\")[-1]} matches {schema_path.split(\"/\")[-1]}') | |
| except jsonschema.ValidationError as e: | |
| print(f' ✗ {fixture_path.split(\"/\")[-1]}: {e.message}') | |
| failed += 1 | |
| sys.exit(1 if failed else 0) | |
| " | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| use_oidc: true | |
| files: ./coverage.out | |
| flags: unittests | |
| name: openboot-coverage | |
| fail_ci_if_error: false | |
| - name: Upload coverage artifacts (on failure) | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: debug-coverage | |
| path: | | |
| coverage.out | |
| coverage.html | |
| retention-days: 7 |