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

ci: simplify #9

Merged
merged 1 commit into from
Jul 11, 2023
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
169 changes: 66 additions & 103 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@ name: CI

on:
push:
branches: [main]
paths-ignore: ['**/*.md']
pull_request:
paths-ignore: ['**/*.md']

env:
WORK_PATH: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/
GHA_PATH: ${{ github.event.repository.name }}-gha
REPO: ${{ github.event.repository.name }}
# The path where the module would be installed with `v install <giturl>`
MOD_PATH: ~/.vmodules/bartender

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Install V
- name: Cache Status
id: cache-status
uses: actions/cache@v3
with:
path: vlang
key: ${{ runner.os }}-v-

- if: ${{ steps.cache-status.outputs.cache-hit != 'true' }}
name: Install V
uses: vlang/[email protected]
with:
check-latest: true
Expand All @@ -28,7 +36,7 @@ jobs:
name: Cache V
uses: actions/cache/save@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-${{ env.V_VER }}

lint:
Expand All @@ -38,27 +46,27 @@ jobs:
simple-build:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
trimming: [null, -skip-unused]
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

- name: Setup V
uses: vlang/[email protected]

- name: Checkout ${{ github.event.repository.name }}
- name: Checkout ${{ env.REPO }}
uses: actions/checkout@v3
with:
path: ${{ env.GHA_PATH }}
path: ${{ env.REPO }}

- name: Copy ${{ env.REPO }} to ${{ env.MOD_PATH }}
run: cp -r ${{ env.REPO }} ${{ env.MOD_PATH }}

- name: ${{ matrix.trimming }} build
run: v -cg -shared ${{ matrix.trimming }} ${{ env.GHA_PATH }}
- name: Build
run: v -cg -shared ${{ env.MOD_PATH }}

test:
needs: simple-build
Expand All @@ -67,97 +75,53 @@ jobs:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

- name: Setup V
uses: vlang/[email protected]

- name: Checkout ${{ github.event.repository.name }}
- name: Checkout ${{ env.REPO }}
uses: actions/checkout@v3
with:
path: ${{ env.GHA_PATH }}

- name: Run tests
run: v test ${{ env.GHA_PATH }}

setup-clang:
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- name: Check if LLVM and Clang is cached
id: check-llvm-cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}llvm
key: llvm-15
path: ${{ env.REPO }}

- if: ${{ steps.check-llvm-cache.outputs.cache-hit != 'true' }}
name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: '15'
- name: Copy ${{ env.REPO }} to ${{ env.MOD_PATH }}
run: cp -r ${{ env.REPO }} ${{ env.MOD_PATH }}

- if: ${{ steps.check-llvm-cache.outputs.cache-hit != 'true' }}
name: Cache LLVM and Clang
uses: actions/cache/save@v3
with:
path: ${{ env.WORK_PATH }}llvm
key: llvm-15
- name: Run tests
run: v test ${{ env.MOD_PATH }}

different-compilers:
needs: setup-clang
needs: simple-build
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
trimming: [null, -skip-unused]
optimization: [null, -prod]
trimming: ['', -skip-unused]
optimization: ['', -prod]
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

- name: Setup V
uses: vlang/[email protected]

- if: ${{ matrix.compiler == 'gcc' }}
name: Setup GCC
run: |
sudo apt-get update
sudo apt-get install --quiet -y build-essential

- if: ${{ matrix.compiler == 'clang' }}
name: Restore LLVM and Clang Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}llvm
key: llvm-15
fail-on-cache-miss: true

- if: ${{ matrix.compiler == 'clang' }}
name: Setup LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: '15'
cached: true

- name: Checkout ${{ github.event.repository.name }}
- name: Checkout
uses: actions/checkout@v3
with:
path: ${{ env.GHA_PATH }}
path: ${{ env.REPO }}

- if: ${{ matrix.compiler == 'clang' }}
name: ${{ matrix.compiler }} ${{ matrix.trimming }} build
run: v -cg -shared -cc ${{ matrix.compiler }} ${{ matrix.trimming }} ${{ env.GHA_PATH }}
- name: Copy ${{ env.REPO }} to ${{ env.MOD_PATH }}
run: cp -r ${{ env.REPO }} ${{ env.MOD_PATH }}

- if: ${{ matrix.compiler == 'gcc' }}
name: ${{ matrix.compiler }} ${{ matrix.trimming }} ${{ matrix.optimization }} build
run: v -cg -shared -cc ${{ matrix.compiler }} ${{ matrix.trimming }} ${{ matrix.optimization }} ${{ env.GHA_PATH }}
- name: ${{ matrix.compiler }} ${{ matrix.trimming }} ${{ matrix.optimization }} build
run: v -cg -shared -cc ${{ matrix.compiler }} ${{ matrix.trimming }} ${{ matrix.optimization }} ${{ env.MOD_PATH }}

clang-sanitizers:
needs: different-compilers
Expand All @@ -169,33 +133,23 @@ jobs:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

- name: Setup V
uses: vlang/[email protected]

- name: Restore LLVM and Clang Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}llvm
key: llvm-15
fail-on-cache-miss: true

- name: Setup LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: '15'
cached: true

- name: Checkout ${{ github.event.repository.name }}
- name: Checkout ${{ env.REPO }}
uses: actions/checkout@v3
with:
path: ${{ env.GHA_PATH }}
path: ${{ env.REPO }}

- name: Copy ${{ env.REPO }} to ${{ env.MOD_PATH }}
run: cp -r ${{ env.REPO }} ${{ env.MOD_PATH }}

- name: Clang ${{ matrix.sanitizer }} sanitizer
run: v -cc clang -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.GHA_PATH }}
run: v -cc clang -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}

gcc-sanitizers:
needs: different-compilers
Expand All @@ -207,7 +161,7 @@ jobs:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

Expand All @@ -219,13 +173,16 @@ jobs:
sudo apt-get update
sudo apt-get install --quiet -y build-essential

- name: Checkout ${{ github.event.repository.name }}
- name: Checkout ${{ env.REPO }}
uses: actions/checkout@v3
with:
path: ${{ env.GHA_PATH }}
path: ${{ env.REPO }}

- name: Copy ${{ env.REPO }} to ${{ env.MOD_PATH }}
run: cp -r ${{ env.REPO }} ${{ env.MOD_PATH }}

- name: GCC ${{ matrix.sanitizer }} sanitizer
run: v -cc gcc -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.GHA_PATH }}
run: v -cc gcc -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}

gcc-address-sanitizers:
needs: different-compilers
Expand All @@ -234,7 +191,7 @@ jobs:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

Expand All @@ -246,13 +203,16 @@ jobs:
sudo apt-get update
sudo apt-get install --quiet -y build-essential

- name: Checkout ${{ github.event.repository.name }}
- name: Checkout ${{ env.REPO }}
uses: actions/checkout@v3
with:
path: ${{ env.GHA_PATH }}
path: ${{ env.REPO }}

- name: Copy ${{ env.REPO }} to ${{ env.MOD_PATH }}
run: cp -r ${{ env.REPO }} ${{ env.MOD_PATH }}

- name: GCC address sanitizer
run: v -cc gcc -cflags -fsanitize=address -cflags -fsanitize-address-use-after-scope -cflags -fsanitize=pointer-compare -cflags -fsanitize=pointer-subtract test ${{ env.GHA_PATH }}
run: v -cc gcc -cflags -fsanitize=address -cflags -fsanitize-address-use-after-scope -cflags -fsanitize=pointer-compare -cflags -fsanitize=pointer-subtract test ${{ env.MOD_PATH }}

gcc-undefined-sanitizers:
needs: different-compilers
Expand All @@ -261,7 +221,7 @@ jobs:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

Expand All @@ -273,10 +233,13 @@ jobs:
sudo apt-get update
sudo apt-get install --quiet -y build-essential

- name: Checkout ${{ github.event.repository.name }}
- name: Checkout ${{ env.REPO }}
uses: actions/checkout@v3
with:
path: ${{ env.GHA_PATH }}
path: ${{ env.REPO }}

- name: Copy ${{ env.REPO }} to ${{ env.MOD_PATH }}
run: cp -r ${{ env.REPO }} ${{ env.MOD_PATH }}

- name: GCC undefined sanitizer
run: v -cc gcc -cflags -fsanitize=undefined -cflags -fsanitize=shift -cflags -fsanitize=shift-exponent -cflags -fsanitize=shift-base -cflags -fsanitize=integer-divide-by-zero -cflags -fsanitize=unreachable -cflags -fsanitize=vla-bound -cflags -fsanitize=null -cflags -fsanitize=return -cflags -fsanitize=signed-integer-overflow -cflags -fsanitize=bounds -cflags -fsanitize=bounds-strict -cflags -fsanitize=alignment -cflags -fsanitize=object-size -cflags -fsanitize=float-divide-by-zero -cflags -fsanitize=float-cast-overflow -cflags -fsanitize=nonnull-attribute -cflags -fsanitize=returns-nonnull-attribute -cflags -fsanitize=bool -cflags -fsanitize=enum -cflags -fsanitize=vptr -cflags -fsanitize=pointer-overflow -cflags -fsanitize=builtin test ${{ env.GHA_PATH }}
run: v -cc gcc -cflags -fsanitize=undefined -cflags -fsanitize=shift -cflags -fsanitize=shift-exponent -cflags -fsanitize=shift-base -cflags -fsanitize=integer-divide-by-zero -cflags -fsanitize=unreachable -cflags -fsanitize=vla-bound -cflags -fsanitize=null -cflags -fsanitize=return -cflags -fsanitize=signed-integer-overflow -cflags -fsanitize=bounds -cflags -fsanitize=bounds-strict -cflags -fsanitize=alignment -cflags -fsanitize=object-size -cflags -fsanitize=float-divide-by-zero -cflags -fsanitize=float-cast-overflow -cflags -fsanitize=nonnull-attribute -cflags -fsanitize=returns-nonnull-attribute -cflags -fsanitize=bool -cflags -fsanitize=enum -cflags -fsanitize=vptr -cflags -fsanitize=pointer-overflow -cflags -fsanitize=builtin test ${{ env.MOD_PATH }}