From 1d51c3d5bc2bddcc0244918e16b49a427acd9636 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Tue, 8 Aug 2023 00:15:20 +0200 Subject: [PATCH] ci: improve caching strategy --- .github/workflows/ci.yml | 163 +++++++++++--------------------- .github/workflows/lint-docs.yml | 23 ++--- .github/workflows/lint.yml | 34 ++----- 3 files changed, 73 insertions(+), 147 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c2a549..2c12058 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 }} @@ -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 }} @@ -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 diff --git a/.github/workflows/lint-docs.yml b/.github/workflows/lint-docs.yml index c9629b1..9f68b65 100644 --- a/.github/workflows/lint-docs.yml +++ b/.github/workflows/lint-docs.yml @@ -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 }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cb91ade..d0784ce 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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/