Skip to content

Commit

Permalink
ci: improve caching strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Aug 7, 2023
1 parent 2e4413d commit 1d51c3d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 147 deletions.
163 changes: 55 additions & 108 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,92 +14,57 @@ 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
- 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
- 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@v3
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
key: ${{ runner.os }}-v-${{ env.V_VER }}
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}

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

simple-build:
test:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
optimization: ['', -cstrict]
steps:
- name: Restore V Cache
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
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
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
path: ${{ env.REPO_NAME }}

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

packages: libcurl4-openssl-dev
version: 1.0
- name: Run tests
run: v test ${{ env.MOD_PATH }}
run: v -cg ${{ matrix.optimization }} test ${{ env.MOD_PATH }}

different-compilers:
needs: test
Expand All @@ -109,27 +74,21 @@ jobs:
compiler: [gcc, clang]
optimization: ['', -prod]
steps:
- name: Restore V Cache
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
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
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
path: ${{ env.REPO_NAME }}

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

packages: libcurl4-openssl-dev
version: 1.0
- name: Build
run: v -cg -shared -cc ${{ matrix.compiler }} ${{ matrix.optimization }} ${{ env.MOD_PATH }}

Expand All @@ -140,27 +99,21 @@ jobs:
matrix:
sanitizer: [address, leak]
steps:
- name: Restore V Cache
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
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
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
path: ${{ env.REPO_NAME }}

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

packages: libcurl4-openssl-dev
version: 1.0
- name: Test
run: v -cc clang -cflags -fsanitize=${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}

Expand All @@ -173,27 +126,21 @@ jobs:
env:
SANITIZER: ${{ matrix.sanitizer }}
steps:
- name: Restore V Cache
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
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
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
path: ${{ env.REPO_NAME }}

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

packages: libcurl4-openssl-dev
version: 1.0
- name: Test
run: |
if [[ $SANITIZER == "address" ]]; then
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/lint-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,17 @@ jobs:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-

path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
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
- name: Setup Dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
path: ${{ env.REPO_NAME }}

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

packages: libcurl4-openssl-dev
version: 1.0
- name: Check Markdown
run: v check-md -hide-warnings ${{ env.MOD_PATH }}
34 changes: 9 additions & 25 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,28 @@ jobs:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true

- name: Setup V
uses: vlang/setup-v@v1.3

- 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: Check Formatting
run: v fmt -verify ${{ env.MOD_PATH }}

vet:
runs-on: ubuntu-latest
steps:
- name: Restore V Cache
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-
path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true

- name: Setup V
uses: vlang/setup-v@v1.3

- 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: Vet ${{ env.REPO_NAME }}
run: v vet -W ${{ env.MOD_PATH }}/src/

0 comments on commit 1d51c3d

Please sign in to comment.