Test partition poc #122
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: v3 | |
BB_VERSION: 1.12.195 | |
CLOJURE_CLI_VERSION: 1.12.0.1479 | |
CLOJURE_CACHE_PATHS: | | |
~/.m2/repository | |
~/.gitlibs | |
~/.deps.clj | |
PARTITION_STRATEGY: ":var-time" | |
TARGET_PARTITION_MINUTES: 3 | |
MIN_PARTITIONS: 5 | |
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 --plugin partition --print-suggested-partitions \ | |
'{:input-file "kaocha-profiling.edn" | |
:target-partition-minutes ${{ env.TARGET_PARTITION_MINUTES }} | |
:default-partitions ${{ env.DEFAULT_PARTITIONS }} | |
:min-partitions ${{ env.MIN_PARTITIONS }} | |
:max-partitions ${{ env.MAX_PARTITIONS }} | |
:partition-strategy ${{ env.PARTITION_STRATEGY }} | |
: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 \ | |
--plugin partition \ | |
--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 ${{ env.PARTITION_STRATEGY }} \ | |
--plugin kaocha.plugin/junit-xml \ | |
--junit-xml-file "junit-${{ strategy.job-index }}.xml" \ | |
--junit-xml-add-location-metadata | |
- 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 | |
junit-${{ strategy.job-index }}.xml | |
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: Upload test timings for manual inspection | |
uses: actions/upload-artifact@v4 | |
with: | |
name: all-kaocha-profiling | |
path: | | |
current-kaocha-profiling-*.edn | |
junit-*.xml | |
compression-level: 0 | |
retention-days: 1 | |
- name: Print test timings | |
run: cat current-kaocha-profiling-*.edn | |
- name: Combine results | |
run: | | |
./bin/kaocha-bb --plugin partition --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 }} | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@992d97d6eb2e5f3de985fbf9df6a04386874114d | |
with: | |
report_paths: "junit-*.xml" | |
include_passed: true | |
summary: true | |
detailed_summary: true | |
flaky_summary: true | |
group_suite: true |