Christoph Reiter 553846537b add some debug logs for JOB_CHECK_RUN_ID
seems like it's not there in some cases (?)
2025-10-05 09:49:19 +02:00

208 lines
6.2 KiB
YAML

name: 'build'
on:
workflow_dispatch:
inputs:
optional_deps:
description: 'optional_deps=pkg-A:optional-dep-B,pkg-C:optional-dep-D'
default: ''
required: false
type: string
context:
description: 'Extra information from invoker'
default: ''
required: false
type: string
schedule:
- cron: '0 0/3 * * *'
env:
PYTHONUNBUFFERED: 1
permissions: {}
jobs:
schedule:
runs-on: ubuntu-24.04
permissions:
contents: write
concurrency: autobuild-maint
outputs:
build-plan: ${{ steps.check.outputs.build-plan }}
steps:
- name: Dump inputs
if: ${{ github.event_name == 'workflow_dispatch' }}
env:
CONTEXT: '${{ toJSON(github.event.inputs) }}'
run: |
echo "$CONTEXT"
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install deps
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
- name: autobuild cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.autobuild_cache
key: autobuild_cache-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: autobuild_cache-
- name: Check what we should run
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
OPTIONAL_DEPS: ${{ github.event.inputs.optional_deps }}
run: |
python -m msys2_autobuild write-build-plan --optional-deps "$OPTIONAL_DEPS" build_plan.json
buildPlan="$(cat build_plan.json)"
echo "build-plan=$buildPlan" >> $GITHUB_OUTPUT
- name: Clean up assets
if: steps.check.outputs.build-plan != '[]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
run: |
python -m msys2_autobuild clean-assets
- name: Show build queue
if: steps.check.outputs.build-plan != '[]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
OPTIONAL_DEPS: ${{ github.event.inputs.optional_deps }}
run: |
python -m msys2_autobuild show --optional-deps "$OPTIONAL_DEPS"
build:
timeout-minutes: 4320
needs: schedule
permissions:
contents: write
concurrency: autobuild-build-${{ matrix.name }}
if: ${{ needs.schedule.outputs.build-plan != '[]' }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.schedule.outputs.build-plan) }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
steps:
- name: Configure Pagefile
if: ${{ matrix.hosted }}
# https://github.com/al-cheb/configure-pagefile-action/issues/16
continue-on-error: true
uses: al-cheb/configure-pagefile-action@a3b6ebd6b634da88790d9c58d4b37a7f4a7b8708
with:
minimum-size: 4GB
maximum-size: 16GB
disk-root: "C:"
- name: Runner details
run: |
Get-PSDrive -PSProvider FileSystem
Get-CIMInstance -Class Win32_Processor | Select-Object -Property Name
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: actions/setup-python@v5
id: python
with:
python-version: '3.13'
# Avoid it setting CMake/pkg-config variables
# https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#environment-variables
update-environment: false
# Work around https://github.com/actions/setup-python/issues/1050
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-${{ runner.arch }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-pip-
- name: Install deps
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
PYTHON_PATH: ${{ steps.python.outputs.python-path }}
run: |
& "$env:PYTHON_PATH" -m venv .venv
.\.venv\Scripts\activate
python -m pip install -r requirements.txt
echo "$env:VIRTUAL_ENV\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: autobuild cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.autobuild_cache
key: autobuild_cache-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: autobuild_cache-
# Note that ARM64 prior to Win11 requires x86 msys, but this will install x64
- uses: msys2/setup-msys2@v2 # zizmor: ignore[unpinned-uses]
id: msys2
with:
msystem: MSYS
update: true
install: ${{ matrix.packages }}
location: '\M'
release: ${{ matrix.hosted }}
cache: ${{ matrix.hosted }}
- name: Switch to the main mirror
shell: msys2 {0}
run: |
echo 'Server = https://repo.msys2.org/mingw/$repo/' > /etc/pacman.d/mirrorlist.mingw
echo 'Server = https://repo.msys2.org/msys/$arch/' > /etc/pacman.d/mirrorlist.msys
pacman-conf.exe
- name: Update using the main mirror & Check install
run: |
msys2 -c 'pacman --noconfirm -Suuy'
msys2 -c 'pacman --noconfirm -Suu'
msys2 -c 'pacman -Qkq'
- name: Process build queue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
# https://github.com/actions/runner/issues/324#issuecomment-3324382354
# https://github.com/actions/runner/pull/4053
JOB_CHECK_RUN_ID: ${{ job.check_run_id }}
MSYS2_ROOT: ${{ steps.msys2.outputs.msys2-location }}
run: |
echo "JOB_CHECK_RUN_ID=$env:JOB_CHECK_RUN_ID"
$BUILD_ROOT=Join-Path (Split-Path $env:GITHUB_WORKSPACE -Qualifier) "\"
python -m msys2_autobuild build ${{ matrix.build-args }} "$env:MSYS2_ROOT" "$BUILD_ROOT"