feat(rust): support compilation for Android #983
Workflow file for this run
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: build | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
rust-hello-linux: | |
strategy: | |
matrix: | |
config: | |
- package: default | |
test-bin: ./result/bin/rust-hello | |
- package: rust-hello | |
test-bin: ./result/bin/rust-hello | |
- package: rust-hello-aarch64-apple-darwin | |
test-bin: file ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-aarch64-linux-android | |
test-bin: file ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-aarch64-unknown-linux-musl | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-armv7-unknown-linux-musleabihf | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-wasm32-unknown-unknown | |
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm | |
- package: rust-hello-wasm32-wasi | |
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm | |
test-oci: docker load < ./result | |
- package: rust-hello-x86_64-apple-darwin | |
test-bin: file ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-x86_64-pc-windows-gnu | |
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/rust-hello.exe | |
test-oci: docker load < ./result | |
- package: rust-hello-x86_64-unknown-linux-musl | |
test-bin: ./result/bin/rust-hello | |
test-oci: | | |
docker load < ./result | |
docker run --rm rust-hello:$(nix eval --raw --override-input 'nixify' '.' ./examples/rust-hello#rust-hello-x86_64-unknown-linux-musl-oci.imageTag) | |
- package: rust-hello-debug | |
test-bin: ./result/bin/rust-hello | |
- package: rust-hello-debug-aarch64-apple-darwin | |
test-bin: file ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-debug-aarch64-unknown-linux-musl | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-debug-aarch64-linux-android | |
test-bin: file ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-debug-armv7-unknown-linux-musleabihf | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-debug-wasm32-wasi | |
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm | |
test-oci: docker load < ./result | |
- package: rust-hello-debug-x86_64-apple-darwin | |
test-bin: file ./result/bin/rust-hello | |
test-oci: docker load < ./result | |
- package: rust-hello-debug-x86_64-pc-windows-gnu | |
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/rust-hello.exe | |
test-oci: docker load < ./result | |
- package: rust-hello-debug-x86_64-unknown-linux-musl | |
test-bin: ./result/bin/rust-hello | |
test-oci: | | |
docker load < ./result | |
docker run --rm rust-hello:$(nix eval --raw --override-input 'nixify' '.' ./examples/rust-hello#rust-hello-x86_64-unknown-linux-musl-oci.imageTag) | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/install-nix | |
with: | |
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: nix build -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#${{ matrix.config.package }}' | |
- run: ${{ matrix.config.test-bin }} | |
- run: nix build -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#${{ matrix.config.package }}-oci' | |
if: ${{ matrix.config.package != 'default' && matrix.config.package != 'rust-hello' && matrix.config.package != 'rust-hello-debug' }} | |
- run: ${{ matrix.config.test-oci }} | |
rust-hello-macos: | |
strategy: | |
matrix: | |
# NOTE: Only build Wasm targets on Darwin here, since Mac machines are extremely slow on GitHub. Other targets are built as part of `rust-complex-macos` | |
config: | |
- package: rust-hello-wasm32-unknown-unknown | |
- package: rust-hello-wasm32-wasi | |
- package: rust-hello-debug-wasm32-unknown-unknown | |
- package: rust-hello-debug-wasm32-wasi | |
runs-on: macos-12 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/install-nix | |
with: | |
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: nix build -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#${{ matrix.config.package }}' | |
- run: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm | |
rust-complex-linux: | |
strategy: | |
matrix: | |
config: | |
- package: default | |
test-bin: ./result/bin/foo | |
- package: rust-complex | |
test-bin: ./result/bin/foo | |
- package: rust-complex-aarch64-apple-darwin | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-aarch64-linux-android | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-aarch64-unknown-linux-musl | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/foo | |
- package: rust-complex-armv7-unknown-linux-musleabihf | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/foo | |
- package: rust-complex-x86_64-apple-darwin | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-x86_64-pc-windows-gnu | |
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/foo.exe | |
suffix: .exe | |
- package: rust-complex-x86_64-unknown-linux-musl | |
test-bin: ./result/bin/foo | |
- package: rust-complex-debug | |
test-bin: ./result/bin/foo | |
- package: rust-complex-debug-aarch64-apple-darwin | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-debug-aarch64-linux-android | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-debug-aarch64-unknown-linux-musl | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/foo | |
- package: rust-complex-debug-armv7-unknown-linux-musleabihf | |
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/foo | |
- package: rust-complex-debug-x86_64-apple-darwin | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-debug-x86_64-pc-windows-gnu | |
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/foo.exe | |
suffix: .exe | |
- package: rust-complex-debug-x86_64-unknown-linux-musl | |
test-bin: ./result/bin/foo | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/install-nix | |
with: | |
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- uses: ./.github/actions/build-nix | |
with: | |
package: ${{ matrix.config.package }} | |
flake: ./examples/rust-complex | |
install-path: /bin/foo${{ matrix.config.suffix }} | |
- run: ${{ matrix.config.test-bin }} | |
rust-complex-macos: | |
strategy: | |
matrix: | |
config: | |
- package: default | |
test-bin: ./result/bin/foo | |
- package: rust-complex | |
test-bin: ./result/bin/foo | |
- package: rust-complex-aarch64-apple-darwin | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-aarch64-unknown-linux-musl | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-armv7-unknown-linux-musleabihf | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-x86_64-apple-darwin | |
test-bin: ./result/bin/foo | |
- package: rust-complex-x86_64-pc-windows-gnu | |
test-bin: file ./result/bin/foo.exe | |
suffix: .exe | |
- package: rust-complex-x86_64-unknown-linux-musl | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-debug | |
test-bin: ./result/bin/foo | |
- package: rust-complex-debug-aarch64-apple-darwin | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-debug-aarch64-unknown-linux-musl | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-debug-armv7-unknown-linux-musleabihf | |
test-bin: file ./result/bin/foo | |
- package: rust-complex-debug-x86_64-apple-darwin | |
test-bin: ./result/bin/foo | |
- package: rust-complex-debug-x86_64-pc-windows-gnu | |
test-bin: file ./result/bin/foo.exe | |
suffix: .exe | |
- package: rust-complex-debug-x86_64-unknown-linux-musl | |
test-bin: file ./result/bin/foo | |
runs-on: macos-12 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/install-nix | |
with: | |
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- uses: ./.github/actions/build-nix | |
with: | |
package: ${{ matrix.config.package }} | |
flake: ./examples/rust-complex | |
install-path: /bin/foo${{ matrix.config.suffix }} | |
- run: ${{ matrix.config.test-bin }} | |
oci-linux: | |
runs-on: ubuntu-22.04 | |
if: ${{ github.event_name != 'pull_request' }} | |
permissions: | |
packages: write | |
needs: | |
- rust-hello-linux | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/install-nix | |
with: | |
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
nix run -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#build-rust-hello-oci' rust-hello | |
nix profile install --inputs-from . 'nixpkgs#buildah' | |
buildah manifest push --all --format 'v2s2' rust-hello docker://ghcr.io/${{ github.repository_owner }}/nixify:rust-hello-${{ github.sha }} | |
docker run ghcr.io/${{ github.repository_owner }}/nixify:rust-hello-${{ github.sha }} | |
test-linux: | |
runs-on: ubuntu-22.04 | |
needs: | |
- rust-complex-linux | |
- oci-linux | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: rust-complex-x86_64-unknown-linux-musl | |
- run: chmod +x ./rust-complex-x86_64-unknown-linux-musl | |
- run: ./rust-complex-x86_64-unknown-linux-musl | |
test-macos: | |
runs-on: macos-12 | |
needs: rust-complex-linux | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: rust-complex-aarch64-apple-darwin | |
- uses: actions/download-artifact@v3 | |
with: | |
name: rust-complex-x86_64-apple-darwin | |
- run: chmod +x ./rust-complex-x86_64-apple-darwin | |
- run: ./rust-complex-x86_64-apple-darwin | |
- run: lipo -create ./rust-complex-aarch64-apple-darwin ./rust-complex-x86_64-apple-darwin -output ./rust-complex-universal-darwin | |
- run: chmod +x ./rust-complex-universal-darwin | |
- run: ./rust-complex-universal-darwin | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: rust-complex-universal-darwin | |
path: rust-complex-universal-darwin | |
test-windows: | |
runs-on: windows-2022 | |
needs: rust-complex-linux | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: rust-complex-x86_64-pc-windows-gnu | |
- run: '& .\rust-complex-x86_64-pc-windows-gnu' | |
test-artifacts: | |
runs-on: ubuntu-22.04 | |
needs: | |
- rust-complex-linux | |
- rust-complex-macos | |
- rust-hello-linux | |
- rust-hello-macos | |
- test-linux | |
- test-macos | |
- test-windows | |
steps: | |
- run: echo "binary artifacts are valid" |