| 1 | # The same workflow on GitHub and on g1t: this file and |
| 2 | # .github/workflows/conformance.yml are kept identical (a test says so). |
| 3 | # Run it by hand on both, then compare what each job saw with |
| 4 | # `node scripts/conformance-diff.mjs github.json g1t.json`; see |
| 5 | # CONTRIBUTING.md, "Checking g1t against GitHub". It changes nothing, |
| 6 | # reads no secrets and never runs on its own. |
| 7 | name: Conformance |
| 8 | |
| 9 | on: |
| 10 | workflow_dispatch: |
| 11 | |
| 12 | permissions: |
| 13 | contents: read |
| 14 | |
| 15 | jobs: |
| 16 | first: |
| 17 | name: First |
| 18 | runs-on: ubuntu-latest |
| 19 | timeout-minutes: 10 |
| 20 | outputs: |
| 21 | value: ${{ steps.out.outputs.value }} |
| 22 | steps: |
| 23 | - id: out |
| 24 | run: echo "value=hello" >> "$GITHUB_OUTPUT" |
| 25 | - name: Something to cache and to pass on |
| 26 | run: | |
| 27 | mkdir -p conformance-cache conformance-artifact |
| 28 | echo "cached" > conformance-cache/file.txt |
| 29 | echo "passed on" > conformance-artifact/file.txt |
| 30 | - uses: actions/cache/save@v4 |
| 31 | with: |
| 32 | path: conformance-cache |
| 33 | key: conformance-${{ github.run_id }}-${{ github.run_attempt }} |
| 34 | - uses: actions/upload-artifact@v4 |
| 35 | with: |
| 36 | name: conformance-artifact |
| 37 | path: conformance-artifact |
| 38 | retention-days: 1 |
| 39 | |
| 40 | report: |
| 41 | name: Report (${{ matrix.n }}) |
| 42 | needs: first |
| 43 | runs-on: ubuntu-latest |
| 44 | timeout-minutes: 10 |
| 45 | strategy: |
| 46 | matrix: |
| 47 | n: [1] |
| 48 | steps: |
| 49 | - uses: actions/checkout@v5 |
| 50 | - name: Environment and path for later steps |
| 51 | run: | |
| 52 | echo "FROM_ENV=set" >> "$GITHUB_ENV" |
| 53 | mkdir -p "$RUNNER_TEMP/conformance-bin" |
| 54 | printf '#!/bin/sh\necho on-path\n' > "$RUNNER_TEMP/conformance-bin/conformance-tool" |
| 55 | chmod +x "$RUNNER_TEMP/conformance-bin/conformance-tool" |
| 56 | echo "$RUNNER_TEMP/conformance-bin" >> "$GITHUB_PATH" |
| 57 | - id: later |
| 58 | name: What a later step sees |
| 59 | run: | |
| 60 | echo "tool=$(conformance-tool)" >> "$GITHUB_OUTPUT" |
| 61 | { |
| 62 | echo "text<<CONFORMANCE_EOF" |
| 63 | echo "line one" |
| 64 | echo "line two" |
| 65 | echo "CONFORMANCE_EOF" |
| 66 | } >> "$GITHUB_OUTPUT" |
| 67 | - id: folder |
| 68 | working-directory: conformance |
| 69 | run: echo "name=$(basename "$PWD")" >> "$GITHUB_OUTPUT" |
| 70 | - id: restore |
| 71 | uses: actions/cache/restore@v4 |
| 72 | with: |
| 73 | path: conformance-cache |
| 74 | key: conformance-${{ github.run_id }}-${{ github.run_attempt }} |
| 75 | - uses: actions/download-artifact@v4 |
| 76 | with: |
| 77 | name: conformance-artifact |
| 78 | path: downloaded |
| 79 | - id: files |
| 80 | run: | |
| 81 | echo "cached=$(cat conformance-cache/file.txt 2>/dev/null)" >> "$GITHUB_OUTPUT" |
| 82 | echo "artifact=$(cat downloaded/file.txt 2>/dev/null)" >> "$GITHUB_OUTPUT" |
| 83 | - name: Report |
| 84 | env: |
| 85 | CTX_GITHUB: ${{ toJSON(github) }} |
| 86 | CTX_RUNNER: ${{ toJSON(runner) }} |
| 87 | CTX_JOB: ${{ toJSON(job) }} |
| 88 | CTX_STRATEGY: ${{ toJSON(strategy) }} |
| 89 | CTX_MATRIX: ${{ toJSON(matrix) }} |
| 90 | CTX_STEPS: ${{ toJSON(steps) }} |
| 91 | CTX_NEEDS: ${{ toJSON(needs) }} |
| 92 | CHECK_NEEDS_OUTPUT: ${{ needs.first.outputs.value }} |
| 93 | CHECK_ENV_FROM_FILE: ${{ env.FROM_ENV }} |
| 94 | CHECK_PATH_FROM_FILE: ${{ steps.later.outputs.tool }} |
| 95 | CHECK_MULTILINE_OUTPUT: ${{ steps.later.outputs.text }} |
| 96 | CHECK_WORKING_DIRECTORY: ${{ steps.folder.outputs.name }} |
| 97 | CHECK_CACHE_HIT: ${{ steps.restore.outputs.cache-hit }} |
| 98 | CHECK_CACHE_CONTENT: ${{ steps.files.outputs.cached }} |
| 99 | CHECK_ARTIFACT_CONTENT: ${{ steps.files.outputs.artifact }} |
| 100 | CHECK_FORMAT: ${{ format('{0}-{1}-{{2}}', 'a', 1) }} |
| 101 | CHECK_CONTAINS: ${{ contains(fromJSON('["a","b"]'), 'b') }} |
| 102 | CHECK_STARTS_WITH: ${{ startsWith('Hello', 'he') }} |
| 103 | CHECK_JOIN: ${{ join(fromJSON('["a","b","c"]'), '+') }} |
| 104 | CHECK_TO_JSON: ${{ toJSON(fromJSON('{"a":[1,2],"b":null}')) }} |
| 105 | CHECK_EQUALITY: ${{ 1 == '1' }} ${{ 'A' == 'a' }} ${{ null == '' }} |
| 106 | CHECK_FALSY_OR: ${{ '' || 'fallback' }} |
| 107 | CHECK_HASH_FILES: ${{ hashFiles('conformance/report.mjs') }} |
| 108 | CHECK_SUCCESS: ${{ success() }} |
| 109 | CHECK_MATRIX: ${{ matrix.n }} |
| 110 | CHECK_JOB_TOTAL: ${{ strategy.job-total }} |
| 111 | CHECK_EVENT_NAME: ${{ github.event_name }} |
| 112 | CHECK_RUNNER_OS: ${{ runner.os }} |
| 113 | run: node conformance/report.mjs conformance.json |
| 114 | - uses: actions/upload-artifact@v4 |
| 115 | with: |
| 116 | name: conformance-report |
| 117 | path: conformance.json |
| 118 | retention-days: 7 |