Skip to content

ci: add linux-amd64 automation baseline (#89) #120

ci: add linux-amd64 automation baseline (#89)

ci: add linux-amd64 automation baseline (#89) #120

name: build and test (linux-amd64)
on:
push:
branches: [thirdparty-linux-amd64]
pull_request:
branches: [thirdparty-linux-amd64]
permissions:
contents: read
env:
CONTRACT_REPOSITORY: vlang/v
CONTRACT_SHA: 7545e515b434cd399333d43659238427d72e22e7
VC_SHA: dfc458a13ba8923ebc249e262c331f8169aa728b
PUBLISH: 'false'
TCCBIN_PUBLISH: 'false'
jobs:
build:
if: >-
github.repository == 'vlang/tccbin' &&
(
(github.event_name == 'pull_request' &&
github.base_ref == 'thirdparty-linux-amd64') ||
(github.event_name == 'push' &&
github.ref == 'refs/heads/thirdparty-linux-amd64')
)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
# thirdparty/libgc/include (headers) and thirdparty/tccbin_tests (the
# shared cross-platform conformance suite - see its README) both live
# in the main v repo, not here.
- name: checkout v (for thirdparty/libgc and thirdparty/tccbin_tests)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: vlang/v
ref: ${{ env.CONTRACT_SHA }}
path: work
fetch-depth: 0
persist-credentials: false
- name: checkout immutable VC bootstrap snapshot
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: vlang/vc
ref: ${{ env.VC_SHA }}
path: .tccbin-bootstrap-vc
fetch-depth: 0
persist-credentials: false
- name: bootstrap contract-bound validator
shell: bash
run: |
set -euo pipefail
validator_work="$RUNNER_TEMP/tccbin-validator-work"
test ! -e "$validator_work"
git -C work config --local core.autocrlf false
git -C .tccbin-bootstrap-vc config --local core.autocrlf false
work/thirdparty/tccbin_automation/bootstrap/bootstrap.sh \
"$GITHUB_WORKSPACE/work" "$CONTRACT_REPOSITORY" "$CONTRACT_SHA" \
"$GITHUB_WORKSPACE/.tccbin-bootstrap-vc" "$validator_work"
{
echo "TCCBIN_VALIDATOR_CLI=$validator_work/tccbin-automation"
echo "TCCBIN_VALIDATOR_CONTRACT_ROOT=$validator_work/contract-source"
} >> "$GITHUB_ENV"
# this branch's already-committed tcc.exe/lib/include, checked out at
# work/thirdparty/tcc - this exact relative layout matters: the
# bundled tcc.exe has a baked-in default of looking for its own
# crt1.o/crti.o/crtn.o/libtcc1.a under "thirdparty/tcc/..." relative
# to the process's working directory (not derived from argv0, and
# not fully honored via -B), matching how V's own build invokes it
# from the repo root. Running it from any other layout breaks those
# lookups with confusing "library not found"/"undefined symbol"
# errors that have nothing to do with the actual test being run -
# reproduced and root-caused locally before writing this workflow.
- name: checkout this branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ github.sha }}
path: work/thirdparty/tcc
fetch-depth: 0
persist-credentials: false
- name: validate baseline manifest and immutable contract binding
shell: bash
run: |
set -euo pipefail
git -C work/thirdparty/tcc config --local core.autocrlf false
bash work/thirdparty/tcc/automation/probes/baseline-contract.sh \
"$TCCBIN_VALIDATOR_CLI" "$TCCBIN_VALIDATOR_CONTRACT_ROOT" \
"$GITHUB_WORKSPACE/work/thirdparty/tcc" linux-amd64 \
thirdparty-linux-amd64 "$CONTRACT_SHA" "$GITHUB_SHA" \
"$GITHUB_WORKSPACE/.tccbin-bootstrap-vc"
- name: run shared conformance tests
working-directory: work
run: |
chmod +x thirdparty/tcc/tcc.exe thirdparty/tccbin_tests/run.sh
# tcc may print "libgc.a: error: 'GC_noop1_ptr' defined twice" -
# this is benign here: thirdparty/libgc/include/gc.h provides a
# weak fallback definition (for vlang/v#27179, so the header is
# usable from plain C without V's codegen), and tcc's ELF linker
# reports the collision with libgc.a's strong definition as a
# diagnostic but still correctly keeps the strong one and links
# successfully - confirmed locally (binary runs fine despite the
# message). Not something this workflow needs to work around.
./thirdparty/tccbin_tests/run.sh ./thirdparty/tcc/tcc.exe linux -- \
-DGC_BUILTIN_ATOMIC=1 \
-I ./thirdparty/libgc/include \
./thirdparty/tcc/lib/libgc.a \
-ldl -lpthread
tccbin-branch-gate:
name: tccbin-branch-gate
if: >-
always() &&
github.repository == 'vlang/tccbin' &&
(
(github.event_name == 'pull_request' &&
github.base_ref == 'thirdparty-linux-amd64') ||
(github.event_name == 'push' &&
github.ref == 'refs/heads/thirdparty-linux-amd64')
)
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: require successful baseline validation
shell: bash
env:
BUILD_RESULT: ${{ needs.build.result }}
run: test "$BUILD_RESULT" = success