Test Snippet Code files #19
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 Snippet Code files | |
| on: | |
| schedule: | |
| - cron: '0 0 1,15 * *' | |
| workflow_dispatch: {} | |
| jobs: | |
| snippet-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 # Or a specific version | |
| - name: Set up environment | |
| uses: ./.github/actions/snippet_setup | |
| - name: Test snippets | |
| if: matrix.files != 'lint' | |
| id: testing_step | |
| shell: bash -l {0} | |
| run: | | |
| sage -python lmfdb/tests/generate_snippet_tests.py generate -i magma -e snippet_error_file.md | |
| - name: Read error file | |
| if: ${{ hashFiles('**/snippet_error_file.md') }} | |
| id: read_error_file | |
| run: | | |
| { | |
| echo 'ERROR_CONTENTS<<EOF' | |
| cat snippet_error_file.md | |
| echo EOF | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create or update snippet error issue | |
| if: ${{ hashFiles('**/snippet_error_file.md') }} | |
| uses: ovsds/create-or-update-unique-issue-action@v1 | |
| with: | |
| title: "(Auto-generated) Errors in code snippets" | |
| body: ${{ steps.read_error_file.outputs.ERROR_CONTENTS }} | |
| unique-title-includes: "(Auto-generated) Errors in code snippets" | |
| - name: Delete error log file | |
| if: ${{ hashFiles('**/snippet_error_file.md') }} | |
| shell: bash -l {0} | |
| run: | | |
| rm snippet_error_file.md | |
| - name: Check for diff | |
| id: diff_check | |
| run: | | |
| # Get the diff and save it to a file. | |
| git diff --relative --exit-code > changes.diff | |
| - name: Report diff | |
| if: ${{ failure() && steps.diff_check.conclusion == 'failure' }} | |
| run: echo "::warning::Nontrivial diff detected. See the 'repo-diff' artifact for details." | |
| - name: Upload diff as artifact | |
| if: ${{ failure() && steps.diff_check.conclusion == 'failure' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: repo-diff | |
| path: changes.diff |