Skip to content

WIP: Test WSL2

WIP: Test WSL2 #139

name: Build toolchain
on:
pull_request:
workflow_dispatch:
inputs:
binutils_branch:
description: 'Binutils branch to build'
required: false
default: 'woarm64'
gcc_branch:
description: 'GCC branch to build'
required: false
default: 'woarm64'
mingw_branch:
description: 'MinGW branch to build'
required: false
default: 'woarm64'
arch:
description: 'Architecture to build for'
required: false
default: 'x86_64'
platform:
description: 'Platform to build for'
required: false
default: 'w64-mingw32'
crt:
description: 'C runtime to build for'
required: false
default: 'msvcrt'
tag:
description: 'Tag to use for the artifact'
required: true
gcc_module:
description: 'GCC module to test'
required: false
default: ''
gcc_test_filter:
description: 'GCC test filter'
required: false
default: ''
workflow_call:
inputs:
binutils_branch:
type: string
gcc_branch:
type: string
mingw_branch:
type: string
arch:
type: string
platform:
type: string
crt:
type: string
tag:
type: string
gcc_module:
type: string
gcc_test_filter:
type: string
env:
DISTRO: 'Ubuntu-22.04'
BINUTILS_BRANCH: ${{ inputs.binutils_branch || 'woarm64' }}
GCC_BRANCH: ${{ inputs.gcc_branch || 'woarm64' }}
MINGW_BRANCH: ${{ inputs.mingw_branch || 'woarm64' }}
ARCH: ${{ inputs.arch || 'x86_64' }}
PLATFORM: ${{ inputs.platform || 'w64-mingw32' }}
CRT: ${{ inputs.crt || 'msvcrt' }}
TAG: ${{ inputs.tag || 'test' }}
MODULE: ${{ inputs.gcc_module || '' }}
FILTER: ${{ inputs.gcc_test_filter || '' }}
CCACHE: 1
RUN_BOOTSTRAP: 1
UPDATE_SOURCES: 1
jobs:
build-and-test-toolchain:
name: Build and test toolchain
runs-on: windows-latest
env:
WSLENV: BINUTILS_BRANCH:GCC_BRANCH:MINGW_BRANCH:ARCH:PLATFORM:CRT:TAG:MODULE:FILTER:CCACHE:RUN_BOOTSTRAP:UPDATE_SOURCES:GITHUB_OUTPUT/p
defaults:
run:
shell: powershell
steps:
- name: Get cache key
id: get-cache-key
run: |
Write-Output "timestamp=$((Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"))" >> "$env:GITHUB_OUTPUT"
- name: Install winget
if: false
uses: Cyberboss/install-winget@v1
- name: Install WSL
if: false
uses: Ubuntu/WSL/.github/actions/wsl-install@main
- name: Install ${{ env.DISTRO }}
run: |
echo $Env:UserName
wsl.exe --set-default-version 2
wsl.exe --update
- name: Install ${{ env.DISTRO }}
run: |
wsl.exe --install --distribution ${{ env.DISTRO }}
- name: Checkout repository
run: |
wsl.exe -d ${{ env.DISTRO }} --cd '~' -- bash "git clone --depth=1 ${{ github.server_url }}/${{ github.repository }}.git -b ${{ github.head_ref || github.ref_name || 'main' }} work"
- name: Get WSL paths
id: get-wsl-paths
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: ${{ env.DISTRO }}
exec: |
cd ~/work
source .github/scripts/config.sh
mkdir -p $BUILD_PATH
mkdir -p $CCACHE_DIR_PATH
mkdir -p $ARTIFACT_PATH
echo "build-path=`wslpath -w $BUILD_PATH`" >> $GITHUB_OUTPUT
echo "ccache-dir-path=`wslpath -w $CCACHE_DIR_PATH`" >> $GITHUB_OUTPUT
echo "artifact-path=`wslpath -w $ARTIFACT_PATH`" >> $GITHUB_OUTPUT
- name: Restore Ccache
uses: actions/cache/restore@v4
with:
path: ${{ steps.get-wsl-paths.outputs.ccache-dir-path }}
key: build-and-test-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }}
restore-keys: build-and-test-gcc-ccache-
- name: Build toolchain
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: ${{ env.DISTRO }}
exec: |
cd ~/work
.github/scripts/build.sh
- name: Save Ccache
if: always()
uses: actions/cache/save@v4
with:
path: ${{ steps.get-wsl-paths.outputs.ccache-dir-path }}
key: build-and-test-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }}
- name: Execute GCC tests
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: ${{ env.DISTRO }}
exec: |
cd ~/work
.github/scripts/toolchain/execute-gcc-tests.sh "${{ env.TAG }}" "${{ env.MODULE }}" "${{ env.FILTER }}"
- name: Create summary
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: ${{ env.DISTRO }}
exec: |
cd ~/work
source .github/scripts/config.sh
.github/scripts/toolchain/create-gcc-summary.sh "${{ env.TAG }}" >> \
$ARTIFACT_PATH/gcc-tests-${{ env.TAG }}/summary.txt
- name: Present summary
run: |
cat ${{ steps.get-wsl-paths.outputs.artifact-path }}\gcc-tests-${{ env.TAG }}\summary.txt >> $env:GITHUB_STEP_SUMMARY
- name: Upload build folder
if: failure()
uses: actions/upload-artifact@v4
with:
name: build
retention-days: 1
path: ${{ steps.get-wsl-paths.outputs.build-path }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gcc-tests-${{ env.TAG }}
path: ${{ steps.get-wsl-paths.outputs.artifact-path }}\gcc-tests-${{ env.TAG }}
retention-days: 30