Test partition poc #78
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test partitioned builds | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
# bump to purge caches | |
ACTIONS_CACHE_VERSION: v2 | |
BB_VERSION: 1.12.195 | |
CLOJURE_CLI_VERSION: 1.12.0.1479 | |
CLOJURE_CACHE_PATHS: | | |
~/.m2/repository | |
~/.gitlibs | |
~/.deps.clj | |
TARGET_PARTITION_MINUTES: 10 | |
MAX_PARTITIONS: 10 | |
DEFAULT_PARTITIONS: 5 | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
test-partitions: ${{ steps.test-partitions.outputs.test-partitions }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore Clojure dependencies | |
id: cache-check | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CLOJURE_CACHE_PATHS }} | |
key: cljdeps-${{ env.ACTIONS_CACHE_VERSION }}-${{ hashFiles('deps.edn', 'bb.edn') }} | |
- name: Prepare java | |
if: steps.cache-check.outputs.cache-hit != 'true' | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Install clojure tools | |
if: steps.cache-check.outputs.cache-hit != 'true' | |
uses: DeLaGuardo/[email protected] | |
with: | |
cli: ${{ env.CLOJURE_CLI_VERSION }} | |
- name: Download Clojure deps | |
if: steps.cache-check.outputs.cache-hit != 'true' | |
working-directory: | |
run: ./bin/kaocha --version | |
- name: Profiling Cache | |
id: profiling | |
uses: actions/cache/restore@v4 | |
with: | |
path: kaocha-profiling.edn | |
key: force-cache-miss-profiling-${{ env.ACTIONS_CACHE_VERSION }}-${{ github.ref }}-${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }} | |
restore-keys: | | |
profiling-${{ env.ACTIONS_CACHE_VERSION }}-${{ github.ref }}-${{ github.sha }}- | |
profiling-${{ env.ACTIONS_CACHE_VERSION }}-${{ github.ref }}- | |
profiling-${{ env.ACTIONS_CACHE_VERSION }}- | |
- name: Ensure profiling file exists | |
run: | | |
if [ ! -f kaocha-profiling.edn ]; then | |
echo '{}' > kaocha-profiling.edn | |
fi | |
set -x | |
cat kaocha-profiling.edn | |
- name: Install clojure tools | |
uses: DeLaGuardo/[email protected] | |
with: | |
bb: ${{ env.BB_VERSION }} | |
- name: Setup matrix partitions | |
id: test-partitions | |
run: | | |
./bin/kaocha-bb --print-suggested-partitions \ | |
'{:input-file "kaocha-profiling.edn" | |
:default-partitions ${{ env.DEFAULT_PARTITIONS }} | |
:max-partitions ${{ env.MAX_PARTITIONS }} | |
:debug "debug-suggested-partitions.txt" | |
:github-actions/set-matrix-output "test-partitions"}' | |
cat debug-suggested-partitions.txt | |
- name: Share profiling results with tests | |
uses: actions/upload-artifact@v4 | |
with: | |
name: kaocha-profiling | |
path: kaocha-profiling.edn | |
test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: setup | |
strategy: | |
fail-fast: false | |
matrix: | |
id: ${{ fromJSON(needs.setup.outputs.test-partitions) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.CLOJURE_CACHE_PATHS }} | |
key: cljdeps-${{ env.ACTIONS_CACHE_VERSION }}-${{ hashFiles('deps.edn', 'bb.edn') }} | |
fail-on-cache-miss: true | |
- name: Download profiling results | |
uses: actions/download-artifact@v4 | |
with: | |
name: kaocha-profiling | |
- name: Ensure profiling file exists | |
run: cat kaocha-profiling.edn | |
- name: Install clojure tools | |
uses: DeLaGuardo/[email protected] | |
with: | |
cli: ${{ env.CLOJURE_CLI_VERSION }} | |
- name: Restore Clojure cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.CLOJURE_CACHE_PATHS }} | |
key: cljdeps-${{ env.ACTIONS_CACHE_VERSION }}-${{ hashFiles('deps.edn', 'bb.edn') }} | |
fail-on-cache-miss: true | |
- name: Run tests | |
run: ./bin/kaocha --read-profiling-file kaocha-profiling.edn --write-profiling-file current-kaocha-profiling-${{ strategy.job-index }}.edn --partition-index ${{ strategy.job-index }} --partitions ${{ strategy.job-total }} --partition-strategy :var-time --target-partition-minutes ${{ env.TARGET_PARTITION_MINUTES }} --max-partitions ${{ env.MAX_PARTITIONS }} | |
- name: Upload profiling results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: current-kaocha-profiling-${{ strategy.job-index }} | |
path: current-kaocha-profiling-${{ strategy.job-index }}.edn | |
result: | |
timeout-minutes: 5 | |
if: ${{!cancelled() && needs.setup.result == 'success'}} | |
runs-on: ubuntu-latest | |
needs: [setup, test] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore Clojure dependencies | |
id: cache-check | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CLOJURE_CACHE_PATHS }} | |
key: cljdeps-${{ env.ACTIONS_CACHE_VERSION }}-${{ hashFiles('deps.edn', 'bb.edn') }} | |
- name: Install clojure tools | |
uses: DeLaGuardo/[email protected] | |
with: | |
bb: ${{ env.BB_VERSION }} | |
- name: Download test timings | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: current-kaocha-profiling-* | |
merge-multiple: true | |
- name: Combine results | |
run: | | |
./bin/kaocha-bb --combine-partitioned-results \ | |
'{:result-files ["current-kaocha-profiling-*.edn"] | |
:output-file "kaocha-profiling.edn"}' | |
- name: Update Profiling Cache | |
id: profiling | |
uses: actions/cache/save@v4 | |
with: | |
path: kaocha-profiling.edn | |
key: profiling-${{ env.ACTIONS_CACHE_VERSION }}-${{ github.ref }}-${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }} |