Create Github Actions workflows #48
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow to build Dawn using CMake | |
name: CMake | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
build_type: [Debug, Release] | |
c_compiler: [clang, cl] | |
include: | |
- os: windows-latest | |
c_compiler: cl | |
cpp_compiler: cl | |
- os: ubuntu-latest | |
c_compiler: clang | |
cpp_compiler: clang++ | |
- os: macos-latest | |
c_compiler: clang | |
cpp_compiler: clang++ | |
exclude: | |
- os: windows-latest | |
c_compiler: clang | |
- os: windows-latest | |
c_compiler: cl | |
build_type: Debug | |
- os: ubuntu-latest | |
c_compiler: cl | |
- os: macos-latest | |
c_compiler: cl | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set reusable strings | |
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | |
id: strings | |
shell: bash | |
run: | | |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
echo "build-key=${{ runner.os }}-${{github.workflow}}-${{ matrix.build_type }}-${{ matrix.c_compiler }}" >> "$GITHUB_OUTPUT" | |
# Only download workspace artifacts on pull requests. CI builds should start from a fresh state. | |
- name: Download workspace artifacts | |
uses: dawidd6/action-download-artifact@v2 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
workflow: ${{ github.workflow }} | |
workflow_conclusion: success | |
name: workspace-${{ steps.strings.outputs.build-key }} | |
search_artifacts: true | |
path: ${{ steps.strings.outputs.build-output-dir }} | |
if_no_artifact_found: ignore | |
- name: Install Ubuntu build dependencies | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt update | |
sudo apt install libgl-dev libx11-xcb-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Fetch dependencies | |
run: python ./tools/fetch_dawn_dependencies.py --use-test-deps --shallow | |
- name: Set up Ninja | |
uses: seanmiddleditch/gha-setup-ninja@master | |
- name: Set up Visual Studio environment | |
if: matrix.os == 'windows-latest' | |
uses: seanmiddleditch/gha-setup-vsdevenv@master | |
- name: Set up sccache | |
uses: mozilla-actions/[email protected] | |
- name: Configure CMake | |
run: > | |
cmake -G Ninja -B ${{ steps.strings.outputs.build-output-dir }} | |
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
-DCMAKE_C_COMPILER_LAUNCHER=sccache | |
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache | |
-S ${{ github.workspace }} | |
env: | |
SCCACHE_GHA_ENABLED: "true" | |
- name: Build | |
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | |
env: | |
SCCACHE_GHA_ENABLED: "true" | |
# Always upload workspace artifacts. Eventually only do this for pushes to main. | |
- name: Upload workspace artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: workspace-${{ steps.strings.outputs.build-key }} | |
path: ${{ steps.strings.outputs.build-output-dir }} | |
retention-days: 7 |