|
| 1 | +name: Test go extractor |
| 2 | +description: Run build, QL tests and optionally basic code sanity checks (formatting and generation) |
| 3 | +inputs: |
| 4 | + run-code-checks: |
| 5 | + description: Whether to run formatting, code and qhelp generation checks |
| 6 | + required: false |
| 7 | + default: false |
| 8 | +runs: |
| 9 | + using: composite |
| 10 | + steps: |
| 11 | + - name: Get go version |
| 12 | + shell: bash |
| 13 | + run: | |
| 14 | + ( |
| 15 | + echo -n "GO_VERSION=" |
| 16 | + bazel run @rules_go//go -- version | sed 's/go version go\(.*\) .*/\1/' |
| 17 | + ) | tee -a "$GITHUB_ENV" |
| 18 | +
|
| 19 | + - name: Set up Go |
| 20 | + uses: actions/setup-go@v5 |
| 21 | + with: |
| 22 | + go-version: ${{ env.GO_VERSION }} |
| 23 | + cache: false |
| 24 | + id: go |
| 25 | + |
| 26 | + - name: Set up CodeQL CLI |
| 27 | + uses: ./.github/actions/fetch-codeql |
| 28 | + |
| 29 | + - name: Enable problem matchers in repository |
| 30 | + shell: bash |
| 31 | + run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;' |
| 32 | + |
| 33 | + - name: Build |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + bazel run go:create-extractor-pack |
| 37 | +
|
| 38 | + - name: Check that all Go code is autoformatted |
| 39 | + if: inputs.run-code-checks == 'true' |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + cd go |
| 43 | + make check-formatting |
| 44 | +
|
| 45 | + - name: Check checked-in generated code |
| 46 | + if: inputs.run-code-checks == 'true' |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + bazel run go:gen |
| 50 | + git add . |
| 51 | + git diff --exit-code HEAD || ( |
| 52 | + echo "please run bazel run //go:gen" |
| 53 | + exit 1 |
| 54 | + ) |
| 55 | +
|
| 56 | + - name: Compile qhelp files to markdown |
| 57 | + if: inputs.run-code-checks == 'true' |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + cd go |
| 61 | + env QHELP_OUT_DIR=qhelp-out make qhelp-to-markdown |
| 62 | +
|
| 63 | + - name: Upload qhelp markdown |
| 64 | + if: inputs.run-code-checks == 'true' |
| 65 | + uses: actions/upload-artifact@v3 |
| 66 | + with: |
| 67 | + name: qhelp-markdown |
| 68 | + path: go/qhelp-out/**/*.md |
| 69 | + |
| 70 | + - name: Cache compilation cache |
| 71 | + id: query-cache |
| 72 | + uses: ./.github/actions/cache-query-compilation |
| 73 | + with: |
| 74 | + key: go-qltest |
| 75 | + |
| 76 | + - name: Test |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + cd go |
| 80 | + make test cache="${{ steps.query-cache.outputs.cache-dir }}" |
0 commit comments