Skip to content

Commit

Permalink
ci: simplify, update concurrency, add macOS workflow (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored Oct 21, 2023
1 parent 3b69c8c commit 5365be5
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 231 deletions.
156 changes: 5 additions & 151 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,158 +7,12 @@ on:
paths-ignore: ['**/*.md']

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

env:
REPO_NAME: ${{ github.event.repository.name }}
MOD_PATH: ~/.vmodules/vibe

jobs:
debounce:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
outputs:
abort: ${{ steps.debounce.outputs.abort }}
steps:
- name: Debounce
if: github.event_name == 'push'
id: debounce
run: |
pr_branches=$(gh pr list --json headRefName --repo $GITHUB_REPOSITORY)
if [[ $(echo "$pr_branches" | jq -r --arg GITHUB_REF '.[].headRefName | select(. == $GITHUB_REF)') ]]; then
echo "This push is associated with a pull request. Skipping the job."
echo "abort=true" >> "$GITHUB_OUTPUT"
fi
setup:
runs-on: ubuntu-20.04
needs: debounce
if: needs.debounce.outputs.abort != 'true'
steps:
- name: Install V
uses: vlang/setup-v@v1.3
with:
check-latest: true
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcurl4-openssl-dev
version: 1.0
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Setup ${{ env.REPO_NAME }}
run: cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }}
- name: Cache
uses: actions/cache/save@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}

lint:
needs: setup
uses: tobealive/vibe/.github/workflows/lint.yml@main

test:
needs: setup
runs-on: ubuntu-20.04
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcurl4-openssl-dev
version: 1.0
- name: Run tests
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 3
command: v -cg test ${{ env.MOD_PATH }}

different-compilers:
needs: test
runs-on: ubuntu-20.04
strategy:
matrix:
cc: [gcc, clang]
optimization: ['', -prod, -cstrict]
fail-fast: false
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcurl4-openssl-dev
version: 1.0
- name: Build
run: v -cg -shared -cc ${{ matrix.cc }} ${{ matrix.optimization }} ${{ env.MOD_PATH }}
- name: Run tests
# TODO: investigate segfaults when running tests in copmiler + optimization combinations
if: matrix.cc != 'gcc' && matrix.optimization != '-prod'
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 3
command: v -cc ${{ matrix.cc }} ${{ matrix.optimization }} test ${{ env.MOD_PATH }}
linux:
uses: ./.github/workflows/linux.yml

test-sanitzed:
needs: different-compilers
runs-on: ubuntu-latest
strategy:
matrix:
cc: [gcc, clang]
sanitizer: [address, leak]
fail-fast: false
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcurl4-openssl-dev
version: 1.0
- name: Run tests
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 3
command: |
if [[ ${{ matrix.cc }} == "gcc" && ${{ matrix.sanitizer }} == "address" ]]; then
cmd="v -cc gcc -cflags -fsanitize=address -cflags -fsanitize-address-use-after-scope -cflags -fsanitize=pointer-compare -cflags -fsanitize=pointer-subtract test ${{ env.MOD_PATH }}"
else
cmd="v -cc ${{ matrix.cc }} -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}"
fi
echo "$cmd"
eval "$cmd"
macos:
uses: ./.github/workflows/macos.yml
81 changes: 62 additions & 19 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,76 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy docs to GitHub Pages
name: Lint Docs

on:
# Runs on pushes targeting the default branch and docs path
push:
branches: ['main']
paths-ignore: ['**/*.yml', '!**/docs.yml']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
paths: ['**/*.md', '**/docs.yml']
pull_request:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REPO_NAME: ${{ github.event.repository.name }}
MOD_PATH: ~/.vmodules/vibe/

jobs:
# Single deploy job since we're just deploying
debounce:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
outputs:
abort: ${{ steps.debounce.outputs.abort }}
steps:
- name: Debounce
if: github.ref_name != 'main' && github.event_name == 'push'
id: debounce
run: |
pr_branches=$(gh pr list --json headRefName --repo $GITHUB_REPOSITORY)
if [[ $(echo "$pr_branches" | jq -r --arg GITHUB_REF '.[].headRefName | select(. == $GITHUB_REF)') ]]; then
echo "This push is associated with a pull request. Skipping the job."
echo "abort=true" >> "$GITHUB_OUTPUT"
fi
check-docs:
runs-on: ubuntu-latest
needs: debounce
if: needs.debounce.outputs.abort != 'true'
steps:
- name: Restore Cache
id: cache-status
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ubuntu-latest${{ github.sha }}
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcurl4-openssl-dev
version: 1.0
- name: Checkout ${{ env.REPO_NAME }}
if: ${{ steps.cache-status.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4
with:
path: ${{ env.REPO_NAME }}
- name: Copy ${{ env.REPO_NAME }} to .vmodules
if: ${{ steps.cache-status.outputs.cache-hit != 'true' }}
run: cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }}
- name: Check Markdown
run: v check-md -hide-warnings ${{ env.MOD_PATH }}

deploy:
concurrency:
group: pages
cancel-in-progress: false
runs-on: ubuntu-latest
if: github.ref_name == 'main' && github.event_name == 'push'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Setup Pages
uses: actions/configure-pages@v3
Expand Down
59 changes: 0 additions & 59 deletions .github/workflows/lint-docs.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
key: ubuntu-latest-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
Expand All @@ -33,7 +33,7 @@ jobs:
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
key: ubuntu-latest-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
Expand Down
Loading

0 comments on commit 5365be5

Please # to comment.