Skip to content

Commit

Permalink
ci: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed May 16, 2024
1 parent 0b88bf9 commit 35d17e6
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 162 deletions.
24 changes: 1 addition & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,12 @@ on:
paths-ignore: ['**/*.md']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref_name == 'main' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
debounce:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
outputs:
abort: ${{ steps.debounce.outputs.abort }}
steps:
- run: printenv
- 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 [[ "$pr_branches" != '[]' && $(echo "$pr_branches" | jq -r --arg GITHUB_REF_NAME '.[].headRefName | select(. == $GITHUB_REF_NAME)') ]]; then
echo "This push is associated with a pull request. Skipping the job."
echo "abort=true" >> "$GITHUB_OUTPUT"
fi
linux:
needs: debounce
if: needs.debounce.outputs.abort != 'true'
uses: ./.github/workflows/linux.yml

macos:
needs: debounce
if: needs.debounce.outputs.abort != 'true'
uses: ./.github/workflows/macos.yml
73 changes: 25 additions & 48 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,64 +12,37 @@ permissions:
pages: write
id-token: write

env:
REPO_NAME: ${{ github.event.repository.name }}
MOD_PATH: ~/.vmodules/vibe/
concurrency:
group: 'pages'
cancel-in-progress: ${{ github.ref_name != 'main' }}

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' && github.ref_name != 'main'
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:
needs: debounce
if: needs.debounce.outputs.abort != 'true'
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Restore Cache
- name: Restore cache
id: cache-status
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: |
vlang
~/v
~/.vmodules
key: ubuntu-latest${{ github.sha }}
- name: Setup V
uses: vlang/[email protected]
run: ~/v/v symlink && v version
- 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 }}
- name: Check markdown
run: v check-md -hide-warnings ~/.vmodules/vibe

deploy:
if: github.event_name == 'push' && github.ref_name == 'main'
if: github.event_name == 'push' && github.ref_name == 'main' && github.repository == 'ttytm/vibe'
runs-on: ubuntu-latest
concurrency:
group: pages
Expand All @@ -78,20 +51,24 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install V
uses: vlang/[email protected]
- name: Setup pages
uses: actions/configure-pages@v5
- name: Restore cache
uses: actions/cache/restore@v4
with:
check-latest: true
- name: Checkout
uses: actions/checkout@v3
path: |
~/v
~/.vmodules
key: ubuntu-latest-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
run: ~/v/v symlink && v version
- name: Build docs
run: docs/build.vsh
run: ~/.vmodules/vibe/docs/build.vsh
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/site'
- name: Deploy to GitHub Pages
- name: Deploy to GitHub pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
36 changes: 9 additions & 27 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,21 @@ name: Lint
on:
workflow_call:

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

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: |
vlang
~/.vmodules
key: ubuntu-latest-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/[email protected]
- name: Check Formatting
run: v fmt -verify ${{ env.MOD_PATH }}

vet:
verify:
runs-on: ubuntu-latest
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
vlang
~/v
~/.vmodules
key: ubuntu-latest-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/[email protected]
- name: Vet ${{ env.REPO_NAME }}
run: v vet -W ${{ env.MOD_PATH }}/src/
run: ~/v/v symlink && v version
- name: Verify formatting
run: v fmt -verify ~/.vmodules/vibe && exit 0 || v fmt -diff . && exit 1
- name: Vet
run: v vet -W ~/.vmodules/vibe
76 changes: 36 additions & 40 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name: CI
on:
workflow_call:

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

jobs:
setup:
strategy:
Expand All @@ -15,26 +11,28 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Install V
uses: vlang/[email protected]
- name: Checkout V
uses: actions/checkout@v4
with:
check-latest: true
repository: 'vlang/v'
path: v
- name: Setup V
run: mv v ~/v && cd ~/v && make -j4
- 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
- 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
path: vibe
- name: Setup V module
run: mv vibe ~/.vmodules/vibe
- name: Save cache
uses: actions/cache/save@v4
with:
path: |
vlang
~/v
~/.vmodules
key: ${{ matrix.os }}-${{ github.sha }}

Expand All @@ -48,67 +46,65 @@ jobs:
matrix:
os: [ubuntu-20.04, ubuntu-latest]
cc: [tcc, gcc, clang]
optimization: ['', -prod, -cstrict]
optimization: ['', '-W -cstrict']
exclude:
- cc: tcc
optimization: -prod
optimization: '-W -cstrict'
fail-fast: false
runs-on: ${{ matrix.os }}
env:
VFLAGS: -cg -stats -cc ${{ matrix.cc }} ${{ matrix.optimization }}
VFLAGS: -cg -cc ${{ matrix.cc }} ${{ matrix.optimization }}
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
vlang
~/v
~/.vmodules
key: ${{ matrix.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/[email protected]
run: ~/v/v symlink && v -showcc self && v doctor
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcurl4-openssl-dev
version: 1.0
- name: Build
run: v -shared ${{ env.MOD_PATH }}
- name: Run tests
run: v ${{ env.VFLAGS }} test ${{ env.MOD_PATH }}
run: v -stats test ~/.vmodules/vibe

test-sanitzed:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
cc: [gcc, clang]
sanitizer: [address, leak]
include:
- cc: gcc
sanitizer: thread
- cc: gcc
sanitizer: address,leak,undefined,shift,shift-exponent,shift-base,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr
- cc: clang
sanitizer: undefined
- cc: clang
sanitizer: memory
fail-fast: false
env:
VFLAGS: -cg -stats -cc ${{ matrix.cc }}
VFLAGS: -cg -cc ${{ matrix.cc }}
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
vlang
~/v
~/.vmodules
key: ubuntu-latest-${{ github.sha }}
fail-on-cache-miss: true
- name: Setup V
uses: vlang/[email protected]
run: ~/v/v symlink && v -showcc self && v doctor
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcurl4-openssl-dev
version: 1.0
- name: Run tests
run: |
if [[ ${{ matrix.cc }} == "gcc" && ${{ matrix.sanitizer }} == "address" ]]; then
cmd="v ${{ env.VFLAGS }} -cflags -fsanitize=address -cflags -fsanitize-address-use-after-scope -cflags -fsanitize=pointer-compare -cflags -fsanitize=pointer-subtract test ${{ env.MOD_PATH }}"
else
cmd="v ${{ env.VFLAGS }} -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}"
fi
echo "$cmd"
eval "$cmd"
run: v -cflags -fsanitize=${{ matrix.sanitizer }} -stats test ~/.vmodules/vibe
Loading

0 comments on commit 35d17e6

Please sign in to comment.