Skip to content

Commit

Permalink
ci: simplify jobs (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored Jul 10, 2023
1 parent 0da8b5b commit 0b8faa2
Showing 1 changed file with 25 additions and 77 deletions.
102 changes: 25 additions & 77 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
paths-ignore: ['**/*.md']

env:
WORK_PATH: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/
MOD_PATH: ~/.vmodules/vibe

jobs:
Expand All @@ -18,7 +17,7 @@ jobs:
id: cache-status
uses: actions/cache@v3
with:
path: ${{ env.WORK_PATH }}vlang/
path: vlang
key: ${{ runner.os }}-v-

- if: ${{ steps.cache-status.outputs.cache-hit != 'true' }}
Expand All @@ -35,7 +34,7 @@ jobs:
name: Cache V
uses: actions/cache/save@v3
with:
path: vlang/
path: vlang
key: ${{ runner.os }}-v-${{ env.V_VER }}

lint:
Expand All @@ -47,13 +46,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
trimming: [null, -skip-unused]
optimization: [null, -cstrict]
optimization: ['', -cstrict]
steps:
- name: Restore V Cache
uses: actions/cache/restore@v3
with:
path: vlang/
path: vlang
key: ${{ runner.os }}-v-
fail-on-cache-miss: true

Expand All @@ -65,12 +63,14 @@ jobs:

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

- name: Copy ${{ github.event.repository.name }} to .vmodules
run: cp -r ${{ env.WORK_PATH }} ${{ env.MOD_PATH }}
run: cp -r ${{ github.event.repository.name }} ${{ env.MOD_PATH }}

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

test:
needs: simple-build
Expand All @@ -79,7 +79,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 @@ -91,95 +91,46 @@ jobs:

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

- name: Copy ${{ github.event.repository.name }} to .vmodules
run: cp -r ${{ env.WORK_PATH }} ${{ env.MOD_PATH }}
run: cp -r ${{ github.event.repository.name }} ${{ env.MOD_PATH }}

- name: Run tests
run: v test ${{ env.MOD_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

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

- 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

different-compilers:
needs: setup-clang
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
trimming: [null, -skip-unused]
optimization: [null, -prod]
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/setup-v@v1.3

- 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: Setup libcurl
run: sudo apt install libcurl4-openssl-dev

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

- name: Copy ${{ github.event.repository.name }} to .vmodules
run: cp -r ${{ env.WORK_PATH }} ${{ env.MOD_PATH }}

- if: ${{ matrix.compiler == 'clang' }}
name: ${{ matrix.compiler }} ${{ matrix.trimming }} build
run: |
cp -r ${{ env.WORK_PATH }} ${{ env.MOD_PATH }}
v -cg -shared -cc ${{ matrix.compiler }} ${{ matrix.trimming }} ${{ env.MOD_PATH }}
run: cp -r ${{ github.event.repository.name }} ${{ 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.MOD_PATH }}
- name: ${{ matrix.compiler }} ${{ matrix.optimization }} build
run: v -cg -shared -cc ${{ matrix.compiler }} ${{ matrix.optimization }} ${{ env.MOD_PATH }}

gcc-sanitizers:
needs: different-compilers
Expand All @@ -191,26 +142,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/setup-v@v1.3

- name: Setup GCC
run: |
sudo apt-get update
sudo apt-get install --quiet -y build-essential
- name: Setup libcurl
run: sudo apt install libcurl4-openssl-dev

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

- name: Copy ${{ github.event.repository.name }} to .vmodules
run: cp -r ${{ env.WORK_PATH }} ${{ env.MOD_PATH }}
run: cp -r ${{ github.event.repository.name }} ${{ env.MOD_PATH }}

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

0 comments on commit 0b8faa2

Please sign in to comment.