@@ -110,86 +110,12 @@ jobs:
110110 run : |
111111 echo "Arch: ${{ matrix.arch }}"
112112 echo "Features: ${{ matrix.features }}"
113- - name : Set arch ${{ matrix.arch }}
114- env :
115- ARCH : ${{ matrix.arch }}
116- run : |
117- if [ "${ARCH}" == "arm64" ]; then
118- echo "rustarch=aarch64-unknown-linux-gnu" >> $GITHUB_ENV
119- elif [ "${ARCH}" == "amd64" ]; then
120- echo "rustarch=x86_64-unknown-linux-gnu" >> $GITHUB_ENV
121- else
122- exit 1
123- fi
124- if [ "$(dpkg --print-architecture)" != "${ARCH}" ]; then
125- echo "Cross-compiling to ${ARCH}."
126- echo "is_cross=true" >> $GITHUB_ENV
127- else
128- echo "Natively compiling to ${ARCH}."
129- echo "is_cross=false" >> $GITHUB_ENV
130- fi
131- - name : Set profile ${{ env.PROFILE }}
132- env :
133- PROFILE : ${{ env.PROFILE }}
134- run : |
135- if [ "${PROFILE}" == "release" ]; then
136- echo "profilestr=--release" >> $GITHUB_ENV
137- elif [ "${PROFILE}" == "debug" ]; then
138- echo "profilestr=" >> $GITHUB_ENV
139- else
140- echo "profilestr=--profile $PROFILE" >> $GITHUB_ENV
141- fi
142- - uses : actions/checkout@v4
143- # - uses: actions-rs/toolchain@v1
144- # if: false
145- # with:
146- # toolchain: stable
147- # override: true
148- # target: ${{ env.rustarch }}
149- - uses : Swatinem/rust-cache@v2
150- with :
151- key : ${{ matrix.arch }}-${{ env.PROFILE }}
152- prefix-key : ${{ inputs.cache-version }}-rust-${{ matrix.features && format('features_{0}', matrix.features) || 'nofeatures' }} # Increase to invalidate old caches.
153- - name : Build (cross to ${{ matrix.arch }})
154- if : env.is_cross == 'true'
155- uses : actions-rs/cargo@v1
156- with :
157- use-cross : ${{ env.is_cross }}
158- command : build
159- args : --target ${{ env.rustarch }} ${{ matrix.features && format('--features {0}', matrix.features) }} ${{ env.profilestr }}
160- - name : Build (native)
161- if : env.is_cross == 'false'
162- run : |
163- OUT=$(cargo build --tests --bins --message-format=json --target ${{ env.rustarch }} ${{ matrix.features && format('--features {0}', matrix.features) }} ${{ env.profilestr }})
164- TESTS=$(echo "$OUT" | jq -r 'select(.profile.test == true) | .executable | select(. != null)')
165- mkdir -p testbinaries/
166- for testbin in $TESTS; do
167- mv -v $testbin testbinaries/
168- done
169- - name : Prepare bins
170- env :
171- PROFILE : ${{ env.PROFILE }}
172- run : |
173- {
174- echo 'bins<<EOF'
175- find target/ -type d -name ${{ env.PROFILE }} -exec find {} -maxdepth 1 -type f -executable \;
176- echo EOF
177- } >> "$GITHUB_ENV"
178- - name : Upload (bins)
179- uses : actions/upload-artifact@v4
180- with :
181- name : binaries-${{ matrix.arch }}-${{ matrix.features }}
182- if-no-files-found : error
183- path : |
184- ${{ env.bins }}
185- - name : Upload (test, native only)
186- if : matrix.arch == 'amd64'
187- uses : actions/upload-artifact@v4
113+ - name : Build
114+ uses : samply/github-workflows/.github/workflows/rust-inner.yml@faster
188115 with :
189- name : testbinaries-${{ matrix.arch }}-${{ matrix.features }}
190- if-no-files-found : error
191- path : |
192- testbinaries/*
116+ architecture : ${{ matrix.arch }}
117+ features : ${{ matrix.features }}
118+ profile : ${{ inputs.profile }}
193119
194120 test :
195121 name : Test
0 commit comments