name: Bootstrapping CI on: workflow_dispatch: push: paths-ignore: - '**.yml' - '**.md' - '**.vv' - '**.out' - 'cmd/tools/**' - '!cmd/tools/builders/**.v' - '!cmd/tools/vup.v' - '!**/bootstrapping_ci.yml' pull_request: paths-ignore: - '**.yml' - '**.md' - '**.vv' - '**.out' - 'cmd/tools/**' - '!cmd/tools/builders/**.v' - '!cmd/tools/vup.v' - '!**/bootstrapping_ci.yml' concurrency: group: bootstrapping-${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} cancel-in-progress: true jobs: bootstrap-v: strategy: matrix: os: [ubuntu-latest, macos-14] fail-fast: false runs-on: ${{ matrix.os }} timeout-minutes: 20 env: VFLAGS: -no-parallel B_LFLAGS: -lm -lpthread steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - name: Build V run: make -j4 - name: Test bootstrapping (v.c can be compiled and run with -os cross) run: | ls -la v vc/v.c ./v -os cross -o vc/v.c cmd/v # shellcheck disable=SC2086 cc -o v_from_vc vc/v.c $B_LFLAGS ls -lart v_from_vc ./v_from_vc version ./v_from_vc run examples/hello_world.v ./v_from_vc -o v_from_vc_produced_native_v cmd/v ./v_from_vc_produced_native_v run examples/hello_world.v ### the next make invocation will simulate building V from scratch make local=1 ls -la v vc/v.c v_from_vc v_from_vc_produced_native_v ./v_from_vc_produced_native_v -os cross -o vc/v.c cmd/v ### do it a second time, just in case: # shellcheck disable=SC2086 clang -o v_from_vc2 vc/v.c $B_LFLAGS ls -lart v_from_vc2 ./v_from_vc2 version ./v_from_vc2 run examples/hello_world.v ./v_from_vc2 -o v_from_vc_produced_native_v2 cmd/v ./v_from_vc_produced_native_v2 run examples/hello_world.v make local=1 ls -la v vc/v.c ls -la v_from_vc v_from_vc_produced_native_v ls -la v_from_vc2 v_from_vc_produced_native_v2 - name: Ensure V master is available if: github.ref_name != 'master' run: git branch master remotes/origin/master - name: Test `v up` run: | # Derive a commit sha from an older successful fast workflow on master that was able to build V. # The workflow used below is `Path Testing CI` (18477644). # Fetch several successful runs and pick the first commit that is actually reachable on master. # Some runs may reference commits from force-pushed branches that are no longer on master. fetch_page() { local page="$1" local body="" for attempt in 1 2 3; do body=$(curl -sL --max-time 30 \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ "https://api.github.com/repos/vlang/v/actions/workflows/18477644/runs?branch=master&status=success&event=push&per_page=10&page=$page") if [ -n "$body" ] && echo "$body" | jq -e '.workflow_runs' >/dev/null 2>&1; then echo "$body" | jq -r '.workflow_runs[].head_sha' return 0 fi echo "::warning::page $page attempt $attempt failed, retrying..." >&2 sleep 5 done return 1 } recent_good_commit="" valid_count=0 for page in 1 2 3; do commits=$(fetch_page "$page" || true) commit_count=$(printf '%s\n' "$commits" | grep -c . || true) echo "page $page: fetched $commit_count commits" for sha in $commits; do if git merge-base --is-ancestor "$sha" master 2>/dev/null; then valid_count=$((valid_count + 1)) echo " valid #$valid_count: $sha" # Skip the first few valid commits to get an older one for testing upgrades. if [ "$valid_count" -ge 5 ]; then recent_good_commit="$sha" break 2 fi fi done done if [ -z "$recent_good_commit" ]; then echo "Path Testing CI lookup yielded only $valid_count valid commits; falling back to git log." recent_good_commit=$(git log master --first-parent --format=%H --before='14 days ago' -n 1) fi if [ -z "$recent_good_commit" ]; then echo "Could not find a valid recent good commit on master" exit 1 fi echo "recent_good_commit=$recent_good_commit" # Build oldv at recent_good_commit. ./v run cmd/tools/oldv.v -v "$recent_good_commit" cd "$HOME/.cache/oldv/v_at_$recent_good_commit" # Test updating ./v version && ./v -v up && ./v version ./v -o v2 cmd/v && ./v2 -o v3 cmd/v