Skip to content

Commit a25f932

Browse files
authored
Enable selective testing for Mac/Linux-Arm jobs (#4361)
1 parent 1b93043 commit a25f932

File tree

10 files changed

+213
-120
lines changed

10 files changed

+213
-120
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# action.yml
2+
inputs:
3+
millargs:
4+
default: ''
5+
type: string
6+
7+
shell:
8+
required: true
9+
type: string
10+
11+
coursierarchive:
12+
default: ''
13+
type: string
14+
15+
install-android-sdk:
16+
default: false
17+
type: boolean
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: actions/setup-node@v4
22+
with: { node-version: '22' }
23+
24+
- run: ./mill -i -k selective.resolve ${{ inputs.millargs }}
25+
shell: ${{ inputs.shell }}
26+
27+
- run: cat out/mill-build/methodCodeHashSignatures.dest/current/spanningInvalidationTree.json
28+
shell: bash
29+
30+
- run: ./mill -i -k selective.resolveTree ${{ inputs.millargs }}
31+
shell: ${{ inputs.shell }}
32+
33+
- run: ./mill -i -k selective.resolveChanged ${{ inputs.millargs }}
34+
shell: ${{ inputs.shell }}
35+
36+
- run: ./mill -i -j1 -k selective.run ${{ inputs.millargs }}
37+
if: ${{ inputs.install-android-sdk }}
38+
env:
39+
COURSIER_ARCHIVE_CACHE: ${{ inputs.coursierarchive }}
40+
shell: ${{ inputs.shell }}
41+
42+
- run: ./mill -i -k selective.run ${{ inputs.millargs }}
43+
if: ${{ !inputs.install-android-sdk }}
44+
env:
45+
COURSIER_ARCHIVE_CACHE: ${{ inputs.coursierarchive }}
46+
shell: ${{ inputs.shell }}
47+
48+
- name: Publish Test Report
49+
uses: mikepenz/action-junit-report@v5
50+
if: always() # always run even if the previous step fails
51+
with:
52+
fail_on_failure: false
53+
include_passed: false
54+
detailed_summary: true
55+
annotate_only: true
56+
require_tests: false
57+
report_paths: 'out/**/test-report.xml'

.github/actions/post-build-setup/action.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ runs:
2222
- run: "chmod -R 777 ."
2323
shell: bash
2424

25-
- uses: coursier/cache-action@v6
26-
2725
- run: git config --global user.email "[email protected]"
2826
shell: bash
2927

3028
- run: git config --global user.name "Your Name"
3129
shell: bash
30+
31+
- uses: actions/download-artifact@v4
32+
with:
33+
path: out/mill-selective-execution
34+
name: ${{ inputs.os }}-selective-execution-artifact
35+
36+
- run: mv out/mill-selective-execution/mill-selective-execution.json out/mill-selective-execution.json
37+
shell: bash
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# action.yml
2+
inputs:
3+
java-version:
4+
required: true
5+
type: string
6+
7+
shell:
8+
required: true
9+
type: string
10+
11+
prepareargs:
12+
default: "__"
13+
type: string
14+
15+
os:
16+
type: string
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
# For normal PR jobs, just checkout the base_ref the PR is against
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.base_ref }}
25+
if: ${{ !(github.event_name == 'push' && github.repository != 'com-lihaoyi/mill') }}
26+
27+
# For fork push jobs, first checkout the version being pushed, then look for the
28+
# merge-base where the current version forks off from the upstream main branch
29+
- uses: actions/checkout@v4
30+
with: { fetch-depth: 0 }
31+
if: ${{ github.event_name == 'push' && github.repository != 'com-lihaoyi/mill' }}
32+
33+
- run: |
34+
git fetch https://github.com/com-lihaoyi/mill main
35+
MERGE_BASE=$(git merge-base FETCH_HEAD HEAD)
36+
# pretty-print the path between the FETCH_HEAD (main), HEAD, and the merge-base
37+
git log --graph --pretty=format:"%h %d %ar %s %n" --ancestry-path $MERGE_BASE^1..HEAD --ancestry-path $MERGE_BASE^1..FETCH_HEAD
38+
39+
git checkout $MERGE_BASE
40+
shell: bash
41+
if: ${{ github.event_name == 'push' && github.repository != 'com-lihaoyi/mill' }}
42+
43+
- run: echo temurin:${{ inputs.java-version }} > .mill-jvm-version
44+
shell: bash
45+
46+
- run: chmod -R 777 . # normalize permissions before and after upload/download-artifact
47+
shell: bash
48+
49+
- run: mkdir out && touch out/mill-selective-execution.json
50+
shell: bash
51+
52+
- run: cat .mill-jvm-version
53+
shell: bash
54+
55+
- run: ./mill -i -k selective.prepare ${{ inputs.prepareargs }}
56+
if: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'run-all-tests')) || github.repository != 'com-lihaoyi/mill' }}
57+
shell: ${{ inputs.shell }}
58+
59+
- uses: actions/[email protected]
60+
with:
61+
path: out/mill-selective-execution.json
62+
name: ${{ inputs.os }}-selective-execution-artifact
63+
include-hidden-files: true
64+
65+
- uses: actions/checkout@v4
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# action.yml
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- uses: android-actions/setup-android@v3
7+
with:
8+
log-accepted-android-sdk-licenses: false
9+
cmdline-tools-version: 11076708
10+
packages: tools platform-tools emulator system-images;android-35;google_apis_playstore;x86_64
11+
12+
- name: Enable KVM group perms
13+
run: |
14+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
15+
sudo udevadm control --reload-rules
16+
sudo udevadm trigger --name-match=kvm
17+
shell: bash
18+
19+
- name: Cleanup any previous avd's to avoid signing key conflicts
20+
run: rm -rf /home/runner/.config/.android/avd
21+
shell: bash
22+
23+
24+
- name: Set AVD environment variable globally
25+
run: echo "ANDROID_AVD_HOME=/home/runner/.config/.android/avd" >> $GITHUB_ENV
26+
shell: bash
27+

.github/workflows/post-build-selective.yml

+12-57
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
millargs:
66
default: ''
77
type: string
8+
9+
shell:
10+
required: true
11+
type: string
12+
813
coursierarchive:
914
default: ''
1015
type: string
@@ -27,6 +32,7 @@ jobs:
2732
continue-on-error: false
2833
timeout-minutes: ${{ inputs.timeout-minutes }}
2934
steps:
35+
- uses: coursier/cache-action@v6
3036

3137
- uses: actions/download-artifact@v4
3238
with:
@@ -38,64 +44,13 @@ jobs:
3844
java-version: ${{ inputs.java-version }}
3945
os: ${{ inputs.os }}
4046

41-
- uses: actions/download-artifact@v4
42-
with:
43-
path: out/mill-selective-execution
44-
name: ${{ inputs.os }}-selective-execution-artifact
45-
46-
- run: mv out/mill-selective-execution/mill-selective-execution.json out/mill-selective-execution.json
47-
48-
- uses: actions/setup-node@v4
49-
with:
50-
node-version: '22'
51-
52-
- uses: android-actions/setup-android@v3
53-
if: ${{ inputs.install-android-sdk }}
54-
with:
55-
log-accepted-android-sdk-licenses: false
56-
cmdline-tools-version: 11076708
57-
packages: tools platform-tools emulator system-images;android-35;google_apis_playstore;x86_64
58-
59-
- name: Enable KVM group perms
60-
if: ${{ inputs.install-android-sdk }}
61-
run: |
62-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
63-
sudo udevadm control --reload-rules
64-
sudo udevadm trigger --name-match=kvm
65-
66-
- name: Cleanup any previous avd's to avoid signing key conflicts
67-
if : ${{ inputs.install-android-sdk }}
68-
run: rm -rf /home/runner/.config/.android/avd
69-
70-
- name: Set AVD environment variable globally
71-
if: ${{ inputs.install-android-sdk }}
72-
run: echo "ANDROID_AVD_HOME=/home/runner/.config/.android/avd" >> $GITHUB_ENV
73-
74-
- run: ./mill -i -k selective.resolve ${{ inputs.millargs }}
75-
76-
- run: cat out/mill-build/methodCodeHashSignatures.dest/current/spanningInvalidationTree.json
77-
78-
- run: ./mill -i -k selective.resolveTree ${{ inputs.millargs }}
79-
80-
- run: ./mill -i -k selective.resolveChanged ${{ inputs.millargs }}
81-
82-
- run: ./mill -i -j1 -k selective.run ${{ inputs.millargs }}
47+
- uses: ./.github/actions/setup-android
8348
if: ${{ inputs.install-android-sdk }}
84-
env:
85-
COURSIER_ARCHIVE_CACHE: ${{ inputs.coursierarchive }}
8649

87-
- run: ./mill -i -k selective.run ${{ inputs.millargs }}
88-
if: ${{ !inputs.install-android-sdk }}
89-
env:
90-
COURSIER_ARCHIVE_CACHE: ${{ inputs.coursierarchive }}
50+
- uses: ./.github/actions/post-build-selective
9151

92-
- name: Publish Test Report
93-
uses: mikepenz/action-junit-report@v5
94-
if: always() # always run even if the previous step fails
9552
with:
96-
fail_on_failure: false
97-
include_passed: false
98-
detailed_summary: true
99-
annotate_only: true
100-
require_tests: false
101-
report_paths: 'out/**/test-report.xml'
53+
millargs: ${{ inputs.millargs }}
54+
coursierarchive: ${{ inputs.coursierarchive }}
55+
install-android-sdk: ${{ inputs.install-android-sdk }}
56+
shell: ${{ inputs.shell }}

.github/workflows/pre-build.yml

+9-42
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
compileargs:
55
default: '__.compile'
66
type: string
7-
prepareargs:
8-
default: '__.test'
9-
type: string
107
java-version:
118
default: '11'
129
type: string
@@ -16,54 +13,24 @@ on:
1613
default: 60
1714
type: number
1815

16+
shell:
17+
required: true
18+
type: string
19+
1920
jobs:
2021
run:
2122
runs-on: ${{ inputs.os }}
2223
timeout-minutes: ${{ inputs.timeout-minutes }}
2324
steps:
2425
# For normal PR jobs, just checkout the base_ref the PR is against
2526
- uses: actions/checkout@v4
26-
with:
27-
ref: ${{ github.base_ref }}
28-
if: ${{ !(github.event_name == 'push' && github.repository != 'com-lihaoyi/mill') }}
29-
30-
# For fork push jobs, first checkout the version being pushed, then look for the
31-
# merge-base where the current version forks off from the upstream main branch
32-
- uses: actions/checkout@v4
33-
with: { fetch-depth: 0 }
34-
if: ${{ github.event_name == 'push' && github.repository != 'com-lihaoyi/mill' }}
35-
36-
- run: |
37-
git fetch https://github.com/com-lihaoyi/mill main
38-
MERGE_BASE=$(git merge-base FETCH_HEAD HEAD)
39-
# pretty-print the path between the FETCH_HEAD (main), HEAD, and the merge-base
40-
git log --graph --pretty=format:"%h %d %ar %s %n" --ancestry-path $MERGE_BASE^1..HEAD --ancestry-path $MERGE_BASE^1..FETCH_HEAD
41-
42-
git checkout $MERGE_BASE
43-
shell: bash
44-
if: ${{ github.event_name == 'push' && github.repository != 'com-lihaoyi/mill' }}
45-
46-
- run: echo temurin:${{ inputs.java-version }} > .mill-jvm-version
27+
with: { fetch-depth: 1 }
4728

48-
- run: chmod -R 777 . # normalize permissions before and after upload/download-artifact
49-
50-
- run: mkdir out && touch out/mill-selective-execution.json
51-
shell: bash
52-
53-
- run: cat .mill-jvm-version
54-
55-
- run: ./mill -i -k selective.prepare ${{ inputs.prepareargs }}
56-
if: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'run-all-tests')) || github.repository != 'com-lihaoyi/mill' }}
57-
58-
- uses: actions/[email protected]
29+
- uses: ./.github/actions/pre-build-setup
5930
with:
60-
path: out/mill-selective-execution.json
61-
name: ${{ inputs.os }}-selective-execution-artifact
62-
include-hidden-files: true
63-
64-
- uses: actions/checkout@v4
65-
66-
- uses: coursier/cache-action@v6
31+
os: ${{ inputs.os }}
32+
java-version: ${{ inputs.java-version }}
33+
shell: ${{ inputs.shell }}
6734

6835
- run: ./mill -i -k ${{ inputs.compileargs }}
6936

0 commit comments

Comments
 (0)