Skip to content

Commit

Permalink
add reusable step
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnite committed Dec 22, 2024
1 parent e5c1b4a commit 83fbac8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 26 deletions.
61 changes: 35 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,22 @@ on:
branches: [main, zig-master]

jobs:
common-setup:
name: Setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [
ubuntu-latest,
windows-latest,
macos-latest,
]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ github.ref == 'refs/heads/zig-master' && 'master' || '0.13.0' }}

build:
name: Build
runs-on: ${{ matrix.os }}
needs: common-setup
continue-on-error: true
steps:
- name: Setup
uses: ./.github/workflows/setup.yml
with:
runner: ${{ matrix.os }}

- name: Build
run: zig build -Doptimize=ReleaseSmall

unit-test-ports:
name: Unit Test Ports
runs-on: ${{ matrix.os }}
needs: common-setup
strategy:
matrix:
os: [
Expand All @@ -51,42 +35,63 @@ jobs:
stmicro/stm32,
]
steps:
- name: Setup
uses: ./.github/workflows/setup.yml
with:
runner: ${{ matrix.os }}

- name: Unit Test Ports
run: zig build test
working-directory: port/${{ matrix.port_dir }}

unit-test-regz:
name: Unit Test Regz
runs-on: ${{ matrix.os }}
needs: common-setup
steps:
- name: Setup
uses: ./.github/workflows/setup.yml
with:
runner: ${{ matrix.os }}

- name: Unit Test Regz
run: zig build test
working-directory: tools/regz

unit-test-uf2:
name: Unit Test UF2
runs-on: ${{ matrix.os }}
needs: common-setup
steps:
- name: Setup
uses: ./.github/workflows/setup.yml
with:
runner: ${{ matrix.os }}

- name: Unit Test UF2
run: zig build test
working-directory: tools/uf2

build-website:
name: Build Website
runs-on: ${{ matrix.os }}
needs: common-setup
steps:
- name: Setup
uses: ./.github/workflows/setup.yml
with:
runner: ${{ matrix.os }}

- name: Build Website
run: zig build
working-directory: website

dry-run-packaging:
name: Dry Run Packaging
runs-on: macos-latest
needs: common-setup
steps:
- name: Setup
uses: ./.github/workflows/setup.yml
with:
runner: macos-latest

- name: Dry Run Packaging
run: |
MICROZIG_VERSION=$(zig build package -- get-version)
Expand All @@ -104,7 +109,6 @@ jobs:
build-examples:
name: Build Examples
runs-on: ubuntu-latest
needs: common-setup
continue-on-error: true
strategy:
matrix:
Expand All @@ -120,6 +124,11 @@ jobs:
wch/ch32v,
]
steps:
- name: Setup
uses: ./.github/workflows/setup.yml
with:
runner: ubuntu-latest

- name: Build Examples
run: zig build -Doptimize=ReleaseSmall --summary all
working-directory: examples/${{ matrix.example_dir }}
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
workflow_call:
inputs:
zig-version:
required: true
type: string

jobs:
setup:
runs-on: ${{ inputs.runner || 'ubuntu-latest' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ github.ref == 'refs/heads/zig-master' && 'master' || '0.13.0' }}

0 comments on commit 83fbac8

Please sign in to comment.