|
5 | 5 | branches: [thirdparty-openbsd-amd64] |
6 | 6 | pull_request: |
7 | 7 | branches: [thirdparty-openbsd-amd64] |
8 | | - workflow_dispatch: {} |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
9 | 11 |
|
10 | 12 | jobs: |
11 | 13 | build: |
| 14 | + name: openbsd-amd64 read-only validation |
| 15 | + if: >- |
| 16 | + github.repository == 'vlang/tccbin' && |
| 17 | + ( |
| 18 | + (github.event_name == 'pull_request' && |
| 19 | + github.base_ref == 'thirdparty-openbsd-amd64') || |
| 20 | + (github.event_name == 'push' && |
| 21 | + github.ref == 'refs/heads/thirdparty-openbsd-amd64') |
| 22 | + ) |
12 | 23 | runs-on: ubuntu-latest |
13 | | - # For a pull_request event, clone the PR's own head repo+commit (so a |
14 | | - # PR that updates tcc.exe/libgc.a is actually tested) instead of the |
15 | | - # unrelated target branch's current tip - a hardcoded |
16 | | - # `git clone --branch thirdparty-openbsd-amd64 .../vlang/tccbin.git` |
17 | | - # would silently test only the already-merged target branch |
18 | | - # regardless of what the PR proposes. push/workflow_dispatch have no |
19 | | - # PR context, so they fall back to the event's own repository/commit |
20 | | - # (not a branch *name*, which is mutable: another push landing while |
21 | | - # this run is queued/starting would otherwise make TCCBIN_CLONE_SHA's |
22 | | - # predecessor, a ref name, silently resolve to a different commit |
23 | | - # than the one that triggered this run - Codex pullrequestreview- |
24 | | - # 4780049532 on vlang/tccbin#76). Set at job level (matching |
25 | | - # update_tccbin.yml's own working BSD job env, which only ever |
26 | | - # references github.*/secrets.*, never steps.* - step-level env on |
27 | | - # the "Start VM" step was tried first and empirically did NOT get |
28 | | - # forwarded into the VM by environment_variables, unlike this |
29 | | - # job-level placement). |
| 24 | + timeout-minutes: 60 |
30 | 25 | env: |
31 | | - TCCBIN_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url || github.event.repository.clone_url }} |
32 | | - TCCBIN_CLONE_SHA: ${{ github.event.pull_request.head.sha || github.sha }} |
| 26 | + TARGET_ID: openbsd-amd64 |
| 27 | + CANONICAL_BRANCH: thirdparty-openbsd-amd64 |
| 28 | + TCCBIN_CLONE_URL: https://github.com/vlang/tccbin |
| 29 | + TCCBIN_CLONE_SHA: ${{ github.sha }} |
| 30 | + CONTRACT_REPOSITORY: vlang/v |
| 31 | + CONTRACT_CLONE_URL: https://github.com/vlang/v |
| 32 | + CONTRACT_SHA: 7545e515b434cd399333d43659238427d72e22e7 |
| 33 | + VC_CLONE_URL: https://github.com/vlang/vc |
| 34 | + VC_SHA: dfc458a13ba8923ebc249e262c331f8169aa728b |
| 35 | + PUBLISH: 'false' |
| 36 | + TCCBIN_PUBLISH: 'false' |
33 | 37 | steps: |
34 | | - # cross-platform-actions/action boots a real OpenBSD VM inside this |
35 | | - # Linux runner - the same action vlang/v's own update_tccbin.yml |
36 | | - # uses to rebuild this branch's binaries. Pinned to the v1.3.0 |
37 | | - # tag's commit (resolved via the GitHub API) rather than the |
38 | | - # mutable tag itself, so a retag upstream can't silently swap in |
39 | | - # different third-party code here without a review-visible diff |
40 | | - # (Codex pullrequestreview-4780049532 on vlang/tccbin#76). |
41 | 38 | - name: Start openbsd-amd64 VM |
42 | | - uses: cross-platform-actions/action@4347c661239bf5dcd0cd77708061488d907343d6 # v1.3.0 |
| 39 | + uses: cross-platform-actions/action@24ef01df165c76df1ed2b9f9e9212e78dc2fc963 # v1.4 |
43 | 40 | with: |
44 | 41 | operating_system: openbsd |
45 | 42 | version: '7.8' |
46 | 43 | memory: 4G |
47 | 44 | shell: sh |
48 | 45 | sync_files: runner-to-vm |
49 | | - environment_variables: TCCBIN_CLONE_URL TCCBIN_CLONE_SHA |
| 46 | + environment_variables: >- |
| 47 | + TARGET_ID CANONICAL_BRANCH |
| 48 | + TCCBIN_CLONE_URL TCCBIN_CLONE_SHA |
| 49 | + CONTRACT_REPOSITORY CONTRACT_CLONE_URL CONTRACT_SHA |
| 50 | + VC_CLONE_URL VC_SHA PUBLISH TCCBIN_PUBLISH |
50 | 51 |
|
51 | | - - name: run shared conformance tests |
52 | | - shell: cpa.sh {0} |
| 52 | + - name: Bootstrap immutable contract and run baseline probe |
| 53 | + shell: cpa.sh {0} --sync-files none |
53 | 54 | run: | |
54 | 55 | set -eu |
55 | | - sudo pkg_add bash git |
| 56 | + umask 077 |
| 57 | + sudo pkg_add bash git boehm-gc |
| 58 | +
|
| 59 | + test "$PUBLISH" = false |
| 60 | + test "$TCCBIN_PUBLISH" = false |
| 61 | + test "$CONTRACT_REPOSITORY" = vlang/v |
| 62 | + test "$CONTRACT_CLONE_URL" = "https://github.com/$CONTRACT_REPOSITORY" |
| 63 | + test "$VC_CLONE_URL" = https://github.com/vlang/vc |
56 | 64 |
|
57 | | - # This branch (unlike linux-amd64/macos-arm64/freebsd-amd64) |
58 | | - # ships no libgc.a/.dylib at all - confirmed by inspecting its |
59 | | - # tree, and matching V's own builder |
60 | | - # (vlib/builtin/builtin_d_gcboehm.c.v's openbsd+tinyc branch), |
61 | | - # which only ever references /usr/local/lib/libgc.a, never a |
62 | | - # bundled path, for this exact platform+compiler combination. |
63 | | - # GC-dependent tests need a system-installed libgc instead. |
64 | | - # OpenBSD's port for this is devel/boehm-gc (confirmed via |
65 | | - # cvsweb.openbsd.org/ports/devel/) - package name is boehm-gc, |
66 | | - # not libgc or gc. |
67 | | - sudo pkg_add boehm-gc |
| 65 | + checkout_exact() { |
| 66 | + checkout_repository=$1 |
| 67 | + checkout_sha=$2 |
| 68 | + checkout_destination=$3 |
| 69 | + checkout_history=$4 |
68 | 70 |
|
69 | | - # Fetch the exact commit that triggered this run, not a branch |
70 | | - # name - `git clone --branch <name>` would resolve whatever |
71 | | - # that name points to *at clone time*, which can race a push |
72 | | - # that lands after this run started (Codex pullrequestreview- |
73 | | - # 4780049532 on vlang/tccbin#76). |
74 | | - mkdir -p thirdparty/tcc && cd thirdparty/tcc |
75 | | - git init -q |
76 | | - git remote add origin "$TCCBIN_CLONE_URL" |
77 | | - git fetch --depth=1 origin "$TCCBIN_CLONE_SHA" |
78 | | - git checkout -q FETCH_HEAD |
79 | | - cd ../.. |
| 71 | + test "${#checkout_sha}" -eq 40 |
| 72 | + case "$checkout_sha" in |
| 73 | + *[!0-9a-f]*) exit 1 ;; |
| 74 | + esac |
| 75 | + test ! -e "$checkout_destination" |
| 76 | + mkdir -p "$checkout_destination" |
| 77 | + git -C "$checkout_destination" init -q |
| 78 | + git -C "$checkout_destination" config --local core.autocrlf false |
| 79 | + git -C "$checkout_destination" remote add origin "$checkout_repository" |
| 80 | + if test "$checkout_history" = shallow; then |
| 81 | + GIT_TERMINAL_PROMPT=0 git -C "$checkout_destination" \ |
| 82 | + fetch --no-tags --depth=1 origin "$checkout_sha" |
| 83 | + else |
| 84 | + GIT_TERMINAL_PROMPT=0 git -C "$checkout_destination" \ |
| 85 | + fetch --no-tags origin "$checkout_sha" |
| 86 | + fi |
| 87 | + git -C "$checkout_destination" checkout -q --detach FETCH_HEAD |
| 88 | + test "$(git -C "$checkout_destination" rev-parse HEAD)" = "$checkout_sha" |
| 89 | + if test "$checkout_history" = full; then |
| 90 | + test "$(git -C "$checkout_destination" \ |
| 91 | + rev-parse --is-shallow-repository)" = false |
| 92 | + fi |
| 93 | + } |
80 | 94 |
|
81 | | - # thirdparty/libgc/include (gc.h) and thirdparty/tccbin_tests |
82 | | - # (the shared cross-platform conformance suite) both live in |
83 | | - # the main v repo, not here. A plain `git clone --depth=1` |
84 | | - # only ever contains the CURRENT tip commit's objects - once |
85 | | - # vlang/v advances past this pinned SHA, that historical |
86 | | - # commit object won't exist in a fresh shallow clone and this |
87 | | - # checkout would fail (the same class of bug Codex flagged as |
88 | | - # P1 on the sibling freebsd-amd64 workflow, pullrequestreview- |
89 | | - # 4780048339 on vlang/tccbin#75 line 60). Fetch that exact SHA |
90 | | - # directly instead of cloning HEAD and hoping it's still there. |
91 | | - mkdir -p vsrc && cd vsrc |
92 | | - git init -q |
93 | | - git remote add origin https://github.com/vlang/v.git |
94 | | - git sparse-checkout init --no-cone |
95 | | - git sparse-checkout set thirdparty/libgc thirdparty/tccbin_tests |
96 | | - git fetch --filter=blob:none --depth=1 origin c82d3f08271e9324d6fb8de3c251e9c0e1a9154b |
97 | | - git checkout -q FETCH_HEAD |
98 | | - cd .. |
| 95 | + mkdir -p "$PWD/thirdparty" |
| 96 | + checkout_exact "$TCCBIN_CLONE_URL" "$TCCBIN_CLONE_SHA" \ |
| 97 | + "$PWD/thirdparty/tcc" shallow |
| 98 | + checkout_exact "$CONTRACT_CLONE_URL" "$CONTRACT_SHA" \ |
| 99 | + "$PWD/vsrc" full |
99 | 100 |
|
100 | | - chmod +x thirdparty/tcc/tcc.exe |
| 101 | + contract_work="$(mktemp -d "${TMPDIR:-/tmp}/tccbin-contract.XXXXXX")" |
| 102 | + vc_root="$contract_work/vc" |
| 103 | + validator_work="$contract_work/validator" |
| 104 | + checkout_exact "$VC_CLONE_URL" "$VC_SHA" "$vc_root" full |
101 | 105 |
|
102 | | - # The bundled tcc.exe resolves its own crt/libtcc1.a via a path |
103 | | - # relative to the process's working directory (confirmed on |
104 | | - # linux-amd64/macos-arm64/freebsd-amd64's CI). |
105 | | - bash vsrc/thirdparty/tccbin_tests/run.sh "$PWD/thirdparty/tcc/tcc.exe" openbsd -- \ |
| 106 | + bash "$PWD/vsrc/thirdparty/tccbin_automation/bootstrap/bootstrap.sh" \ |
| 107 | + "$PWD/vsrc" "$CONTRACT_REPOSITORY" "$CONTRACT_SHA" \ |
| 108 | + "$vc_root" "$validator_work" |
| 109 | +
|
| 110 | + test -x "$validator_work/tccbin-automation" |
| 111 | + test -d "$validator_work/contract-source" |
| 112 | + chmod +x "$PWD/thirdparty/tcc/tcc.exe" |
| 113 | + PUBLISH=false TCCBIN_PUBLISH=false \ |
| 114 | + bash "$PWD/thirdparty/tcc/automation/probes/baseline-contract.sh" \ |
| 115 | + "$validator_work/tccbin-automation" \ |
| 116 | + "$validator_work/contract-source" \ |
| 117 | + "$PWD/thirdparty/tcc" \ |
| 118 | + "$TARGET_ID" "$CANONICAL_BRANCH" "$CONTRACT_SHA" \ |
| 119 | + "$TCCBIN_CLONE_SHA" "$vc_root" |
| 120 | +
|
| 121 | + - name: run shared conformance tests |
| 122 | + shell: cpa.sh {0} --sync-files none |
| 123 | + run: | |
| 124 | + set -eu |
| 125 | + bash vsrc/thirdparty/tccbin_tests/run.sh \ |
| 126 | + "$PWD/thirdparty/tcc/tcc.exe" openbsd -- \ |
106 | 127 | -DGC_BUILTIN_ATOMIC=1 \ |
107 | 128 | -I "$PWD/vsrc/thirdparty/libgc/include" \ |
108 | 129 | -L/usr/local/lib -I/usr/local/include -lgc -lpthread |
| 130 | +
|
| 131 | + tccbin-branch-gate: |
| 132 | + name: tccbin-branch-gate |
| 133 | + if: >- |
| 134 | + always() && |
| 135 | + github.repository == 'vlang/tccbin' && |
| 136 | + ( |
| 137 | + (github.event_name == 'pull_request' && |
| 138 | + github.base_ref == 'thirdparty-openbsd-amd64') || |
| 139 | + (github.event_name == 'push' && |
| 140 | + github.ref == 'refs/heads/thirdparty-openbsd-amd64') |
| 141 | + ) |
| 142 | + needs: [build] |
| 143 | + runs-on: ubuntu-latest |
| 144 | + timeout-minutes: 5 |
| 145 | + steps: |
| 146 | + - name: require successful OpenBSD validation |
| 147 | + shell: bash |
| 148 | + env: |
| 149 | + BUILD_RESULT: ${{ needs.build.result }} |
| 150 | + run: | |
| 151 | + set -euo pipefail |
| 152 | + test "$BUILD_RESULT" = success |
0 commit comments