61
61
fail-fast : false
62
62
matrix :
63
63
job :
64
- - os : arm-4core-linux
64
+ - os : ubuntu-22.04-arm
65
65
image : linux-aarch64
66
66
- os : ubuntu-22.04
67
67
image : linux-x86_64
@@ -85,92 +85,69 @@ jobs:
85
85
86
86
# On pull requests, ensure that changed files are determined before checking out the code so
87
87
# that we use the GitHub API, otherwise we would have to fetch the entire history (depth: 0)
88
- - name : Get changed files
88
+ - name : Check for builder changes (pull request)
89
+ id : changed-files-pr
90
+ if : github.event_name == 'pull_request'
91
+ env :
92
+ GH_TOKEN : " ${{ github.token }}"
93
+ run : |
94
+ PR_NUMBER="${{ github.event.pull_request.number }}"
95
+ REPO="${{ github.repository }}"
96
+
97
+ BUILDERS_CHANGED=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" | \
98
+ jq -r 'map(.filename) | map(select(startswith(".builders/"))) | length > 0')
99
+
100
+ echo "builders_any_changed=$BUILDERS_CHANGED" >> $GITHUB_OUTPUT
101
+
102
+ # For push events, we still need to check changes but will rely on minimal checkout
103
+ - name : Check for builder changes (push)
104
+ id : changed-files-push
105
+ if : github.event_name != 'pull_request'
106
+ run : |
107
+ CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
108
+ echo "builders_any_changed=$(echo "$CHANGED_FILES" | grep -q "^\.builders/" && echo "true" || echo "false")" >> $GITHUB_OUTPUT
109
+
110
+ # Combine outputs for subsequent steps
111
+ - name : Combine changed files outputs
89
112
id : changed-files
90
- uses : tj-actions/changed-files@v42
91
- with :
92
- files_yaml : |-
93
- builders:
94
- - .builders/**
95
- dependencies:
96
- - ${{ env.DIRECT_DEPENDENCY_FILE }}
113
+ run : |
114
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
115
+ echo "builders_any_changed=${{ steps.changed-files-pr.outputs.builders_any_changed }}" >> $GITHUB_OUTPUT
116
+ else
117
+ echo "builders_any_changed=${{ steps.changed-files-push.outputs.builders_any_changed }}" >> $GITHUB_OUTPUT
118
+ fi
97
119
98
120
- name : Checkout code
99
121
if : github.event_name == 'pull_request'
100
122
uses : actions/checkout@v4
101
123
102
124
- name : Set up Python ${{ env.PYTHON_VERSION }}
103
- if : matrix.job.image != 'linux-aarch64'
104
125
uses : actions/setup-python@v5
105
126
with :
106
127
python-version : ${{ env.PYTHON_VERSION }}
107
128
108
- - name : Set up Python (with miniconda) and other aarch64 requirements
109
- if : matrix.job.image == 'linux-aarch64'
110
- run : |
111
- mkdir -p ~/miniconda3
112
- wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.5.0-0-Linux-aarch64.sh -O ~/miniconda3/miniconda.sh
113
- bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
114
- rm -rf ~/miniconda3/miniconda.sh
115
- ~/miniconda3/bin/conda init bash
116
-
117
- # jq
118
- wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-arm64 -O ~/miniconda3/bin/jq
119
- chmod +x ~/miniconda3/bin/jq
120
-
121
- echo "PATH=~/miniconda3/bin/:${PATH}" >> "$GITHUB_ENV"
122
- echo DOCKER="sudo docker" >> "$GITHUB_ENV"
123
-
124
129
- name : Install management dependencies
125
130
run : |
126
131
pip install -r .builders/deps/host_dependencies.txt
127
132
128
- - name : Install docker and log in (arm64)
129
- if : matrix.job.image == 'linux-aarch64'
130
- run : |
131
- curl -fsSL https://get.docker.com -o get-docker.sh
132
- sudo sh get-docker.sh
133
-
134
- # Logging in with sudo is necessary to get authorized with the registry when running docker under sudo
135
- echo ${{ secrets.GITHUB_TOKEN }} | sudo docker login --username ${{ github.actor }} --password-stdin ghcr.io
136
-
137
133
- name : Log in to GitHub Packages
138
- if : matrix.job.image != 'linux-aarch64'
139
134
uses : docker/login-action@v3
140
135
with :
141
136
registry : ghcr.io
142
137
username : ${{ github.actor }}
143
138
password : ${{ secrets.GITHUB_TOKEN }}
144
139
145
- - name : Build image and wheels (arm64)
146
- if : steps.changed-files.outputs.builders_any_changed == 'true' && matrix.job.image == 'linux-aarch64'
147
- run : |-
148
- sudo /home/runner/miniconda3/bin/python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3
149
- # Give ownership of the output back to the user
150
- sudo chown ${USER} ${{ env.OUT_DIR }}
151
-
152
- - name : Pull image and build wheels (arm64)
153
- if : steps.changed-files.outputs.builders_any_changed != 'true' && matrix.job.image == 'linux-aarch64'
154
- run : |-
155
- digest=$(jq -r '.["${{ matrix.job.image }}"]' .deps/image_digests.json)
156
- sudo /home/runner/miniconda3/bin/python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3 --digest $digest
157
-
158
140
- name : Build image and wheels
159
- if : steps.changed-files.outputs.builders_any_changed == 'true' && matrix.job.image != 'linux-aarch64'
141
+ if : steps.changed-files.outputs.builders_any_changed == 'true'
160
142
run : |-
161
143
python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3
162
144
163
145
- name : Pull image and build wheels
164
- if : steps.changed-files.outputs.builders_any_changed != 'true' && matrix.job.image != 'linux-aarch64'
146
+ if : steps.changed-files.outputs.builders_any_changed != 'true'
165
147
run : |-
166
148
digest=$(jq -r '.["${{ matrix.job.image }}"]' .deps/image_digests.json)
167
149
python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3 --digest $digest
168
150
169
- - name : Change permissions
170
- if : matrix.job.image == 'linux-aarch64'
171
- run : |
172
- sudo chmod 777 ${{ env.OUT_DIR }}
173
-
174
151
- name : Publish image
175
152
if : github.event_name == 'push' && steps.changed-files.outputs.builders_any_changed == 'true'
176
153
run : ${DOCKER} push ${{ env.BUILDER_IMAGE }}
0 commit comments