Skip to content

CI

CI #2669

Workflow file for this run

name: CI
on:
schedule:
- cron: '30 5 * * *'
push:
branches:
- master
pull_request:
branches:
- '*'
jobs:
changes:
# Disable the filter on scheduled runs because we don't want to skip those
if: github.event_name != 'schedule'
continue-on-error: true # Makes sure errors won't stop us
runs-on: ubuntu-latest
outputs:
src: ${{ steps.filter.outputs.src }}
steps:
# For PRs the path filter check with Github API, so no need to checkout
# for them.
- if: github.event_name != 'pull_request'
name: Checkout (if not PR)
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- '**.cfg'
- '**.nims'
- '**.nim'
- '**.nimble'
- 'tests/**'
- '.github/workflows/ci.yml'
build:
# Build if the files we care about are changed.
needs: changes
# Make sure to always run regardless of whether the filter success or not.
# When the filter fails there won't be an output, so checking for `false`
# state is better than checking for `true`.
#
# The always() function here is required for the job to always run despite
# what Github docs said, see: https://github.com/actions/runner/issues/491
if: always() && !cancelled() && needs.changes.outputs.src != 'false'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
compiler:
- name: nim
version: devel
broken: true
- name: nim
version: version-2-0
broken: false
- name: nimskull
version: "*"
broken: false
- name: nimskull
version: "0.1.0-dev.21407"
broken: false
name: "${{ matrix.os }} (${{ matrix.compiler.name }} ${{ matrix.compiler.version }}${{ matrix.compiler.broken && ', broken' || '' }})"
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.compiler.broken }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: project
- name: Compiler (nim)
if: matrix.compiler.name == 'nim'
uses: alaviss/[email protected]
with:
path: nim
version: ${{ matrix.compiler.version }}
- name: Compiler (nimskull)
id: nimskull
if: matrix.compiler.name == 'nimskull'
uses: nim-works/[email protected]
with:
nimskull-version: ${{ matrix.compiler.version }}
- if: matrix.compiler.name == 'nimskull'
name: Fetch nimble's fork for nimskull
uses: actions/checkout@v4
with:
path: nimble
repository: alaviss/nimble
ref: nimskull
- if: matrix.compiler.name == 'nimskull'
name: Build nimble and add to PATH
shell: bash
run: |
cd nimble
nim c -d:release -o:nimble src/nimble.nim
cp nimble "$NIMSKULL_BIN/nimble"
# Add nimble binary folder to PATH too
echo "$HOME/.nimble/bin" >> $GITHUB_PATH
env:
NIMSKULL_BIN: ${{ steps.nimskull.outputs.bin-path }}
- name: Valgrind
shell: bash
run: |
sudo apt-get update
sudo apt install --fix-missing valgrind
- name: Dependencies
shell: bash
run: |
cd project
nimble --accept develop
nimble --accept install "https://github.com/disruptek/balls"
env:
NIM: ${{ matrix.compiler.name }}
- name: Examples
shell: bash
run: |
cd project
cd examples
balls '***' --path=".." --backend:c --mm:arc --mm:orc
env:
NIM: ${{ matrix.compiler.name }}
- name: Tutorial
shell: bash
run: |
cd project
cd tutorial
balls '***' --path=".." --backend:c --mm:arc --mm:orc
env:
NIM: ${{ matrix.compiler.name }}
- name: Tests
shell: bash
run: |
cd project
balls --path="." --backend:c --mm:arc --mm:orc --errorMax:3
- name: Docs
if: ${{ matrix.docs }} == 'true'
shell: bash
run: |
cd project
branch=${{ github.ref }}
branch=${branch##*/}
nimble doc --project --outdir:docs --path="." \
'--git.url:https://github.com/${{ github.repository }}' \
'--git.commit:${{ github.sha }}' \
"--git.devel:$branch" \
cps.nim
# Ignore failures for older Nim
cp docs/{the,}index.html || true
- name: Pages
if: >
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
matrix.os == 'ubuntu-latest' && matrix.nim == 'devel'
uses: crazy-max/[email protected]
with:
build_dir: project/docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Set check-required on this
success:
needs: build
if: always()
runs-on: ubuntu-latest
name: 'All check passes'
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
name: 'Fail when previous jobs fails'
run: |
echo "::error::One of the previous jobs failed"
exit 1