Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github/workflows: add CI workflow #74

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: CI
on:
push:
pull_request:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
fail-fast: false
matrix:
compiler:
- name: nim
version: devel
- name: nim
version: version-2-0
- name: nimskull
version: "0.1.0-dev.21405"
- name: nimskull
version: "*"

include:
- compiler:
name: nim
version: devel
build_doc: true

name: ${{ matrix.compiler.name }} ${{ matrix.compiler.version }}
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: npeg

steps:
- name: Checkout
uses: actions/[email protected]
with:
path: npeg

- name: Setup Nim
if: matrix.compiler.name == 'nim'
uses: alaviss/[email protected]
with:
path: nim
version: ${{ matrix.compiler.version }}

- name: Setup nimskull
id: nimskull
if: matrix.compiler.name == 'nimskull'
uses: nim-works/[email protected]
with:
nimskull-version: ${{ matrix.compiler.version }}

- name: Run tests
run: nim r --path:src tests/tests.nim

- name: Build docs
if: matrix.build_doc
shell: bash
run: |
branch=$GITHUB_REF
branch=${branch##*/}
for i in src/npeg.nim src/npeg/*.nim; do
nim doc --project --outdir:htmldocs \
--path:src \
"--git.url:https://github.com/$GITHUB_REPOSITORY" \
"--git.commit:$GITHUB_SHA" \
"--git.devel:$branch" \
"$i"
done
# Make npeg module the default page
cp htmldocs/{npeg,index}.html

- name: Upload GitHub Pages artifact
if: matrix.build_doc
uses: actions/[email protected]
with:
path: npeg/htmldocs

deploy:
needs:
- build
if: github.ref == 'refs/heads/master'

permissions:
actions: read
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

name: Deploy docs to GitHub Pages
runs-on: ubuntu-latest
steps:
- name: Deploy page
id: deployment
uses: actions/[email protected]

passed:
needs: build
if: failure() || cancelled()
name: All tests passed

runs-on: ubuntu-latest
steps:
- run: exit 1
Loading