Skip to content

Commit

Permalink
ci: rework
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Sep 18, 2024
1 parent 49a8a8d commit 46d154b
Showing 1 changed file with 97 additions and 27 deletions.
124 changes: 97 additions & 27 deletions .github/workflows/west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ${{ matrix.os === "ubuntu-latest" }} # 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/[email protected]
- uses: cargo-bins/[email protected]
- run: rustup show
- run: cargo test --workspace --all-targets
- run: cargo binstall -y [email protected]
- 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: ${{ matrix.os === "ubuntu-latest" }} # 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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 46d154b

Please sign in to comment.