From 212ad78611e50f3a8e96dfd12513ed5d21eb2ce3 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Wed, 18 Sep 2024 10:50:52 +0200 Subject: [PATCH] ci: rework Signed-off-by: Roman Volosatovs --- .github/workflows/west.yml | 124 +++++++++++++++++++++++++++++-------- 1 file changed, 97 insertions(+), 27 deletions(-) diff --git a/.github/workflows/west.yml b/.github/workflows/west.yml index 25c7706..aacbb64 100644 --- a/.github/workflows/west.yml +++ b/.github/workflows/west.yml @@ -20,44 +20,115 @@ concurrency: cancel-in-progress: true jobs: - build: + build-ffi: + strategy: + matrix: + target: + - aarch64-unknown-linux-musl + - aarch64-apple-darwin + - aarch64-linux-android + - riscv64gc-unknown-linux-gnu + - x86_64-apple-darwin + - x86_64-pc-windows-gnu + - x86_64-unknown-linux-musl + + name: west-${{ matrix.target }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: ./.github/actions/install-nix + with: + cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - uses: ./.github/actions/build-nix + with: + package: west-${{ matrix.target }} + + build-wasm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - run: nix profile install --inputs-from . '.#rust' 'nixpkgs#wasm-tools' + - run: cargo build -p west-passthrough --target wasm32-unknown-unknown --release + - run: wasm-tools component new target/wasm32-unknown-unknown/release/west_passthrough.wasm -o lib/passthrough.wasm + - uses: actions/upload-artifact@v4 + with: + name: passthrough + path: lib/passthrough.wasm + + test-release: strategy: matrix: config: - - os: ubuntu-latest - lib: x86_64-linux - target: x86_64-unknown-linux-musl + - os: ubuntu-latest + lib: x86_64-linux + target: x86_64-unknown-linux-musl - - os: windows-latest - lib: x86_64-windows - target: x86_64-pc-windows-msvc + - os: windows-latest + lib: x86_64-windows + target: x86_64-pc-windows-gnu - - os: macos-13 - lib: x86_64-darwin - target: x86_64-apple-darwin + - os: macos-13 + lib: x86_64-darwin + target: x86_64-apple-darwin - - os: macos-14 - lib: aarch64-darwin - target: aarch64-apple-darwin + - os: macos-14 + lib: aarch64-darwin + target: aarch64-apple-darwin + needs: + - build-fii + - build-wasm runs-on: ${{ matrix.config.os }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: passthrough + path: lib/passthrough.wasm + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: west-${{ matrix.config.target }} + path: lib/${{ matrix.config.lib }}/libwest.a + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - run: go test ./... + continue-on-error: true # TODO: remove + + test-dev: + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-13 + - macos-14 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - run: rustup show - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' - uses: Swatinem/rust-cache@v2.7.3 - uses: cargo-bins/cargo-binstall@v1.10.5 - - run: rustup show - - run: cargo test --workspace --all-targets - run: cargo binstall -y wasm-tools@1.217 - - run: go generate ./... - - run: go test ./... - - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + - run: cargo test --workspace --all-targets + - run: go generate -tags=dev ./... + - run: go test -tags=dev ./... + continue-on-error: true # TODO: remove + - run: git diff --exit-code + + gofmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/setup-go@v5 with: - name: west-${{ matrix.config.target }} - path: lib/${{ matrix.config.lib }}/libwest.a - if-no-files-found: error + go-version-file: 'go.mod' + - run: gofmt -w -s **/*.go + - run: git diff --exit-code cargo: strategy: @@ -169,7 +240,9 @@ jobs: release: if: startsWith(github.ref, 'refs/tags/v') needs: - - build + - build-ffi + - build-wasm + - test-release - cargo - crates runs-on: ubuntu-latest @@ -204,13 +277,10 @@ jobs: path: artifacts - run: | + mkdir -p ./libwest for dir in ./artifacts/west-*; do target=${dir#./artifacts/west-} - for lib_path in $(find ${dir}/lib -type f); do - lib=$(basename ${lib_path}) - mkdir -p ./${lib} - mv ${lib_path} ./${lib}/${lib}-${target}.a - done + mv ${dir}/lib/libwest_sys.a ./libwest/libwest-${target}.a done - uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8