Skip to content

ci: add sanitizer tests #78

ci: add sanitizer tests

ci: add sanitizer tests #78

Workflow file for this run

name: CI
on:
push:
paths-ignore: ['**/*.md']
pull_request:
paths-ignore: ['**/*.md']
env:
REPO_NAME: ${{ github.event.repository.name }}
MOD_PATH: ~/.vmodules/vibe
jobs:
setup:
runs-on: ubuntu-latest
steps:
- 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/setup-v@v1.3
with:
check-latest: true
- if: ${{ steps.cache-status.outputs.cache-hit != 'true' }}
name: Add V Version to Environment
run: echo "V_VER=$(v -v)" >> $GITHUB_ENV
- if: ${{ steps.cache-status.outputs.cache-hit != 'true' }}
name: Cache V
uses: actions/cache/save@v3
with:
path: vlang
key: ${{ runner.os }}-v-${{ env.V_VER }}
lint:
needs: setup
uses: tobealive/vibe/.github/workflows/lint.yml@main
simple-build:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
optimization: ['', -cstrict]
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup libcurl
run: sudo apt update && sudo apt install libcurl4-openssl-dev
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
with:
path: ${{ env.REPO_NAME }}
- name: Copy ${{ env.REPO_NAME }} to .vmodules
run: cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }}
- name: ${{ matrix.optimization }} build
run: v -cg -shared ${{ matrix.optimization }} ${{ env.MOD_PATH }}
test:
needs: simple-build
runs-on: ubuntu-latest
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup libcurl
run: sudo apt update && sudo apt install libcurl4-openssl-dev
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
with:
path: ${{ env.REPO_NAME }}
- name: Copy ${{ env.REPO_NAME }} to .vmodules
run: cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }}
- name: Run tests
run: v test ${{ env.MOD_PATH }}
different-compilers:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
optimization: ['', -prod]
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup libcurl
run: sudo apt update && sudo apt install libcurl4-openssl-dev
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
with:
path: ${{ env.REPO_NAME }}
- name: Copy ${{ env.REPO_NAME }} to .vmodules
run: cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }}
- name: Build
run: v -cg -shared -cc ${{ matrix.compiler }} ${{ matrix.optimization }} ${{ env.MOD_PATH }}
clang-sanitizers:
needs: different-compilers
runs-on: ubuntu-latest
strategy:
matrix:
sanitizer: [address, leak]
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup libcurl
run: sudo apt update && sudo apt install libcurl4-openssl-dev
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
with:
path: ${{ env.REPO_NAME }}
- name: Copy ${{ env.REPO_NAME }} to .vmodules
run: cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }}
- name: Test
run: v -cc clang -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}
gcc-sanitizers:
needs: different-compilers
runs-on: ubuntu-latest
strategy:
matrix:
sanitizer: [leak, address]
env:
SANITIZER: ${{ matrix.sanitizer }}
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true
- name: Setup V
uses: vlang/setup-v@v1.3
- name: Setup libcurl
run: sudo apt update && sudo apt install libcurl4-openssl-dev
- name: Checkout ${{ env.REPO_NAME }}
uses: actions/checkout@v3
with:
path: ${{ env.REPO_NAME }}
- name: Copy ${{ env.REPO_NAME }} to .vmodules
run: cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }}
- name: Test
run: |
if [[ $SANITIZER == "address" ]]; then
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
v -cc gcc -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}
fi