From 65debfbfbef0150169a7e04d4360f2a7f2004978 Mon Sep 17 00:00:00 2001 From: takonomura Date: Tue, 8 Aug 2023 14:49:52 +0900 Subject: [PATCH 1/2] Add support for aarch64 --- .github/workflows/release.yaml | 16 +++++++++++- .github/workflows/test.yaml | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a9b7878..1f8ceee 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,6 +13,8 @@ jobs: - name: Setup Rust uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 + with: + target: aarch64-unknown-linux-gnu - name: Setup Zig uses: goto-bus-stop/setup-zig@6fede2f0550d71291c0accf2834b216e69a2d67a # v2.1.1 @@ -33,8 +35,20 @@ jobs: command: zigbuild args: --target x86_64-unknown-linux-gnu.2.17 --release + - name: Build (aarch64) + uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3 + with: + command: zigbuild + args: --target aarch64-unknown-linux-gnu.2.17 --release + + - name: Rename aarch64 artifact + run: | + mv target/aarch64-unknown-linux-gnu/release/libnss_jsonfile{,-aarch64}.so + - name: Release uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15 if: startsWith(github.ref, 'refs/tags/') with: - files: target/x86_64-unknown-linux-gnu/release/libnss_jsonfile.so + files: | + target/x86_64-unknown-linux-gnu/release/libnss_jsonfile.so + target/aarch64-unknown-linux-gnu/release/libnss_jsonfile-aarch64.so diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 30a6cca..7eb8251 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -86,3 +86,51 @@ jobs: - name: Test run: | ./test.sh + + aarch64: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - name: Setup Rust + uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 + with: + target: aarch64-unknown-linux-gnu + + - name: Setup Zig + uses: goto-bus-stop/setup-zig@6fede2f0550d71291c0accf2834b216e69a2d67a # v2.1.1 + with: + version: 0.11.0 # renovate: zig-version + + - name: Install cargo-zigbuild + run: | + CARGO_ZIGBUILD_VERSION=v0.17.0 + curl -sSLO "https://github.com/rust-cross/cargo-zigbuild/releases/download/${CARGO_ZIGBUILD_VERSION}/cargo-zigbuild-${CARGO_ZIGBUILD_VERSION}.x86_64-unknown-linux-musl.tar.gz" + tar xf "cargo-zigbuild-${CARGO_ZIGBUILD_VERSION}.x86_64-unknown-linux-musl.tar.gz" cargo-zigbuild + mv cargo-zigbuild /usr/local/bin/ + rm "cargo-zigbuild-${CARGO_ZIGBUILD_VERSION}.x86_64-unknown-linux-musl.tar.gz" + + - name: Build + uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3 + with: + command: zigbuild + args: --target aarch64-unknown-linux-gnu.2.17 --release + + - name: Setup QEMU + uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0 + with: + platforms: arm64 + + - name: Test + run: | + expected="testuser1:*:2001:2001::/home/testuser:/bin/bash" + result="$(docker run --rm \ + --volume "$PWD/examples/passwd.json":/etc/passwd.json:ro \ + --volume "$TARGET":/lib/aarch64-linux-gnu/libnss_jsonfile.so.2:ro \ + --platform linux/arm64 \ + docker.io/library/debian:buster \ + getent -s jsonfile passwd testuser1)" + echo "expected: $expected" + echo " got: $result" + [ "$result" = "$expected" ] || exit 1 From 553e5db8e1076758c3739cd5cb4e693a25af77f5 Mon Sep 17 00:00:00 2001 From: takonomura Date: Tue, 8 Aug 2023 14:53:56 +0900 Subject: [PATCH 2/2] Fix test --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7eb8251..43dd9f0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -127,7 +127,7 @@ jobs: expected="testuser1:*:2001:2001::/home/testuser:/bin/bash" result="$(docker run --rm \ --volume "$PWD/examples/passwd.json":/etc/passwd.json:ro \ - --volume "$TARGET":/lib/aarch64-linux-gnu/libnss_jsonfile.so.2:ro \ + --volume "$PWD/target/aarch64-unknown-linux-gnu/release/libnss_jsonfile.so":/lib/aarch64-linux-gnu/libnss_jsonfile.so.2:ro \ --platform linux/arm64 \ docker.io/library/debian:buster \ getent -s jsonfile passwd testuser1)"