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: improve caching strategy #17

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
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
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/[email protected]
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/[email protected]

- 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/[email protected]

- 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/[email protected]

- 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/[email protected]

- 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/[email protected]

- 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
21 changes: 12 additions & 9 deletions .github/workflows/lint-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Restore Cache
id: cache-status
uses: actions/cache/restore@v3
with:
path: vlang
key: ${{ runner.os }}-v-

path: |
vlang
~/.vmodules
key: ${{ runner.os }}-${{ github.sha }}
- name: Setup V
uses: vlang/[email protected]

- name: Setup libcurl
run: sudo apt update && sudo apt install libcurl4-openssl-dev

- 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@v3
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 }}
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/[email protected]

- 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/[email protected]

- 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/