Use native Build host runner for Ziran checks and skip ccache symlinks in CheckExecutable
Build check / check (push) Failing after 20m44s
Build check / Publish a new Ziran version (push) Skipped

This commit is contained in:
waozi committed 2026-11-21 15:32:46 -03:00
1 parent eb53af7dae
commit 5db3d3c394
3 files changed
+176 -10

No files matched your search

+52 -8
View File
@@ -11,47 +11,70 @@ on:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: check
runs-on: alpha-ziran
runs-on: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 'build-native-ziran' || 'alpha-ziran' }}
timeout-minutes: 90
env:
JOBS: 2
BUILD_NATIVE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 'true' || 'false' }}
steps:
- name: Check out the exact Build commit
id: native
if: env.BUILD_NATIVE == 'true'
run: gitea-native-build checkout
- uses: actions/checkout@v4
if: env.BUILD_NATIVE == 'false'
# site_pages.sh marks std modules shipped in the latest v* tag.
with:
fetch-depth: 0
- uses: actions/setup-go@v5
if: env.BUILD_NATIVE == 'false'
with:
go-version: '1.25'
cache: false
# tests/zstd_go_cases.zi builds against this module with GOPROXY=off,
# and the module itself requires Go 1.25.
- name: Fetch the Go Zstandard module for the offline Go checks
if: env.BUILD_NATIVE == 'false'
run: cd "$RUNNER_TEMP" && go mod download github.com/klauspost/[email protected]
- name: Install ripgrep, MinGW, Wine, Vorbis, ARMv7 tools and the private display for the test scripts
if: env.BUILD_NATIVE == 'false'
timeout-minutes: 5
run: sh scripts/ci_packages.sh ccache ripgrep zip unzip gcc-mingw-w64-x86-64 wine wine64 xvfb xauth libsdl2-dev ffmpeg libvorbis-dev python3-markdown gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user clang-18 lld-18
# The emcc checks use the Emscripten the playground and the site use;
# Ubuntu's emscripten package is 3.1.6, and its emcc is a symlink to a
# wrapper that cannot run under its resolved name.
- name: Set up Emscripten
if: env.BUILD_NATIVE == 'false'
uses: emscripten-core/setup-emsdk@v15
with:
version: '6.0.6'
- name: Keep compile results between runs
if: env.BUILD_NATIVE == 'false'
uses: ./.github/actions/compile-cache
with:
key: check
- name: Verify the cached native toolchain and Go modules
if: env.BUILD_NATIVE == 'true' && steps.native.outputs.current == 'true'
run: gitea-native-build run bash -ec 'emcc --version && go mod download github.com/klauspost/[email protected]'
- name: Build the toolchain
run: make
if: env.BUILD_NATIVE == 'false' || steps.native.outputs.current == 'true'
run: |
if [ "$BUILD_NATIVE" = true ]; then
gitea-native-build run make
else
make
fi
- name: Run the language, backend, and portable runtime checks
run: env -u DISPLAY -u WAYLAND_DISPLAY WINDOWS_REQUIRED=1 ARM_REQUIRED=1 WASM_REQUIRED=1 ZIRAN_WASM_CC=clang-18 make check CHECK_JOBS=2
if: env.BUILD_NATIVE == 'false' || steps.native.outputs.current == 'true'
run: |
if [ "$BUILD_NATIVE" = true ]; then
gitea-native-build run env -u DISPLAY -u WAYLAND_DISPLAY WINDOWS_REQUIRED=1 ARM_REQUIRED=1 WASM_REQUIRED=1 ZIRAN_WASM_CC=clang-18 make check CHECK_JOBS=2 </dev/null
else
env -u DISPLAY -u WAYLAND_DISPLAY WINDOWS_REQUIRED=1 ARM_REQUIRED=1 WASM_REQUIRED=1 ZIRAN_WASM_CC=clang-18 make check CHECK_JOBS=2 </dev/null
fi
- name: Pack the tested Ziran toolchain
id: toolchain
if: github.server_url == 'https://git.waozi.xyz' && github.event_name == 'push' && github.ref == 'refs/heads/master' && (env.BUILD_NATIVE != 'true' || steps.native.outputs.current == 'true')
@@ -89,10 +112,31 @@ jobs:
done
- name: Show how much the compile cache saved
if: always()
run: ccache --show-stats || true
run: |
if [ "$BUILD_NATIVE" = true ]; then
gitea-native-build run ccache --show-stats || true
else
ccache --show-stats || true
fi
- name: Keep complete check logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: check-logs
path: build/check-logs/
path: ${{ steps.native.outputs.source || github.workspace }}/build/check-logs/
release:
name: Publish a new Ziran version
needs: check
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: build-native-ziran
permissions:
contents: write
steps:
- name: Check out the tested Build commit
run: /usr/local/libexec/gitea-native-build checkout
- name: Publish the tested VERSION to Gitea
env:
ZIRAN_RELEASE_BEFORE: ${{ github.event.before }}
ZIRAN_RELEASE_TOKEN: ${{ github.token }}
run: /usr/local/libexec/gitea-native-build run python3 scripts/release_gitea.py
+116
View File
@@ -0,0 +1,116 @@
#!/usr/bin/env python3
"""Publish a tested Ziran version from its Gitea master push."""
import json
import os
from pathlib import Path
import re
import subprocess
from urllib.error import HTTPError
from urllib.request import HTTPRedirectHandler, ProxyHandler, Request, build_opener
REPOSITORY = 'ziranlang/ziran'
REVISION = re.compile('[0-9a-f]{40}')
VERSION = re.compile(r'(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)')
class NoRedirects(HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
def api_client(origin, token):
if not re.fullmatch(r'http://127\.0\.0\.1:[1-9][0-9]{0,4}', origin) or not token:
raise ValueError('Expected the managed Build API and Actions job credential')
endpoint = f'{origin}/api/v1/repos/{REPOSITORY}'
opener = build_opener(ProxyHandler({}), NoRedirects)
def request(method, path, data=None):
headers = {'Authorization': 'token '+token, 'Content-Type': 'application/json'}
target = Request(endpoint+path, method=method, headers=headers,
data=json.dumps(data).encode() if data is not None else None)
with opener.open(target, timeout=15) as response:
return json.load(response)
return request
def get_optional(api, path):
try:
return api('GET', path)
except HTTPError as error:
if error.code == 404:
return None
raise
def release_notes(changelog, version):
headings = list(re.finditer(r'(?m)^## \[([^\]]+)\].*$', changelog))
for index, heading in enumerate(headings):
if heading[1] == version:
end = headings[index+1].start() if index+1 < len(headings) else len(changelog)
notes = changelog[heading.end():end].strip()
if notes:
return notes
raise ValueError('The new VERSION needs a populated CHANGELOG.md section')
def publish(api, previous, version, revision, changelog):
if not VERSION.fullmatch(previous) or not VERSION.fullmatch(version) or not REVISION.fullmatch(revision):
raise ValueError('Expected a numeric release version and an exact source commit')
if version == previous:
return None
if tuple(map(int, version.split('.'))) <= tuple(map(int, previous.split('.'))):
raise ValueError('VERSION must advance to publish a release')
notes = release_notes(changelog, version)
if api('GET', '/branches/master')['commit']['id'] != revision:
return None
tag = 'v'+version
tag_path = '/tags/'+tag
release_path = '/releases/tags/'+tag
existing_tag = get_optional(api, tag_path)
if existing_tag is not None and existing_tag['commit']['sha'] != revision:
raise ValueError(f'{tag} is already attached to a different commit')
release = get_optional(api, release_path)
if release is None:
try:
api('POST', '/releases', {'tag_name': tag, 'target_commitish': revision, 'name': 'Ziran '+version,
'body': notes, 'draft': False, 'prerelease': False, 'tag_message': 'Ziran '+version})
except HTTPError as error:
if error.code != 409:
raise
release = api('GET', release_path)
if (api('GET', tag_path)['commit']['sha'] != revision or release['tag_name'] != tag
or release['draft'] or release['prerelease']):
raise ValueError('Gitea did not return a published release for the tested commit')
return tag
def checked_git(*args):
return subprocess.check_output(['git', *args], text=True, timeout=15).strip()
def main():
env = os.environ
if (env.get('GITHUB_REPOSITORY'), env.get('GITHUB_EVENT_NAME'), env.get('GITHUB_REF')) != (
REPOSITORY, 'push', 'refs/heads/master'):
raise ValueError('Release requires the Ziran master push job')
revision = env['GITHUB_SHA']
before = env['ZIRAN_RELEASE_BEFORE']
if not REVISION.fullmatch(before) or before == '0'*40 or checked_git('rev-parse', 'HEAD') != revision:
raise ValueError('Release requires the checked master push and its preceding commit')
previous = checked_git('show', before+':VERSION')
version = Path('VERSION').read_text().strip()
if previous == version:
print('VERSION is unchanged.')
return
subprocess.run(['git', 'merge-base', '--is-ancestor', before, revision], check=True, timeout=15)
api = api_client(env['BUILD_NATIVE_GIT_ORIGIN'], env.pop('ZIRAN_RELEASE_TOKEN'))
tag = publish(api, previous, version, revision, Path('CHANGELOG.md').read_text())
if tag:
print(f'Published and verified https://git.waozi.xyz/{REPOSITORY}/releases/tag/{tag}')
else:
print('A newer master commit is already at Gitea.')
if __name__ == '__main__':
main()
+8 -2
View File
@@ -34,14 +34,20 @@ CheckWalkInputs :: (directory: string, paths: *Vec(string)) -> bool {
CheckExecutable :: (name: string) -> string {
if TextContains(name, "/") {
status := PathStatus(name)
if status.kind == .File && (status.mode & 73) != 0 { return TextDetach(ResolvePath(name)) }
if status.kind == .File && (status.mode & 73) != 0 {
resolved := TextDetach(ResolvePath(name))
if PathName(name) == "ccache" || PathName(resolved) != "ccache" { return resolved }
}
return ""
}
folders := TextSplit(EnvironmentText("PATH"), ":")
for folder: folders {
path := CheckPath(ifx folder == "" then "." else folder, name)
status := PathStatus(path)
if status.kind == .File && (status.mode & 73) != 0 { return TextDetach(ResolvePath(path)) }
if status.kind == .File && (status.mode & 73) != 0 {
resolved := TextDetach(ResolvePath(path))
if name == "ccache" || PathName(resolved) != "ccache" { return resolved }
}
}
return ""
}