From a332923974dbe160dfc56cd5c6f93dba05b6055f Mon Sep 17 00:00:00 2001 From: Cam Saul Date: Mon, 12 Aug 2024 19:19:05 +0000 Subject: [PATCH] More GH Actions tweaks --- .github/actions/setup-clojure/action.yml | 34 +++++++++ .github/workflows/deploy.yml | 19 +----- .github/workflows/tests.yml | 87 ++++-------------------- 3 files changed, 52 insertions(+), 88 deletions(-) create mode 100644 .github/actions/setup-clojure/action.yml diff --git a/.github/actions/setup-clojure/action.yml b/.github/actions/setup-clojure/action.yml new file mode 100644 index 0000000..c5be8de --- /dev/null +++ b/.github/actions/setup-clojure/action.yml @@ -0,0 +1,34 @@ +name: Setup Clojure +inputs: + clojure-version: + required: true + default: "1.11.4" + java-version: + required: true + default: "17" + cache-key: + required: true + +runs: + using: composite + steps: + - name: Prepare JDK + uses: actions/setup-java@v3 + with: + java-version: ${{ inputs.java-version }} + distribution: 'temurin' + - name: Setup Clojure + uses: DeLaGuardo/setup-clojure@9.5 + with: + cli: ${{ inputs.clojure-version }} + - name: Restore cache + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository + ~/.gitlibs + ~/.deps.clj + key: v1-${{ hashFiles('./deps.edn') }}-${{ inputs.cache-key }} + restore-keys: | + v1-${{ hashFiles('./deps.edn') }}- + v1- diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 15aa8c1..6a43b92 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,23 +13,10 @@ jobs: - uses: actions/checkout@v4.1.0 with: fetch-depth: 0 - - name: Prepare JDK 17 - uses: actions/setup-java@v3 + - name: Setup Java & Clojure + uses: ./.github/actions/setup-clojure with: - java-version: 17 - distribution: 'temurin' - - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@12.1 - with: - cli: 1.11.1.1413 - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - ~/.gitlibs - ~/.deps.clj - key: deploy + cache-key: deploy - name: Build JAR run: clojure -T:build build env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c7d113d..b13fa8b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,15 +15,10 @@ jobs: DOWNLOAD_URL: https://github.com/clj-kondo/clj-kondo/releases/download steps: - uses: actions/checkout@v4 - - name: Prepare JDK 17 - uses: actions/setup-java@v3 + - name: Setup Java & Clojure + uses: ./.github/actions/setup-clojure with: - java-version: 17 - distribution: 'temurin' - - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@9.5 - with: - cli: 1.11.1.1155 + cache-key: kondo - name: Install clj-kondo run: | curl -OL ${DOWNLOAD_URL}/v${CLJ_KONDO_VERSION}/clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip @@ -52,23 +47,10 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - name: Prepare JDK 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: 'temurin' - - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@9.5 - with: - cli: 1.11.1.1155 - - name: Restore cache - uses: actions/cache@v3 + - name: Setup Java & Clojure + uses: ./.github/actions/setup-clojure with: - path: | - ~/.m2/repository - ~/.gitlibs - ~/.deps.clj - key: tests-postgres + cache-key: tests - run: clojure -X:dev:test name: Run tests env: @@ -78,23 +60,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - name: Prepare JDK 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: 'temurin' - - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@9.5 - with: - cli: 1.11.1.1155 - - name: Restore cache - uses: actions/cache@v3 + - name: Setup Java & Clojure + uses: ./.github/actions/setup-clojure with: - path: | - ~/.m2/repository - ~/.gitlibs - ~/.deps.clj - key: whitespace-linter + cache-key: whitespace-linter - run: clojure -T:whitespace-linter name: Run whitespace linter @@ -102,23 +71,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - name: Prepare JDK 17 - uses: actions/setup-java@v3 + - name: Setup Java & Clojure + uses: ./.github/actions/setup-clojure with: - java-version: 17 - distribution: 'temurin' - - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@9.5 - with: - cli: 1.11.1.1155 - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - ~/.gitlibs - ~/.deps.clj - key: check + cache-key: check - run: clojure -M:check name: Check namespaces @@ -126,23 +82,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - name: Prepare JDK 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: 'temurin' - - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@9.5 - with: - cli: 1.11.1.1155 - - name: Restore cache - uses: actions/cache@v3 + - name: Setup Java & Clojure + uses: ./.github/actions/setup-clojure with: - path: | - ~/.m2/repository - ~/.gitlibs - ~/.deps.clj - key: codecov + cache-key: codecov - run: clojure -X:dev:test-h2:cloverage name: Run tests with Cloverage - name: Upload results to codecov.io