diff --git a/.github/workflows/build_matrix.yml b/.github/workflows/build_matrix.yml new file mode 100644 index 0000000..ef52356 --- /dev/null +++ b/.github/workflows/build_matrix.yml @@ -0,0 +1,99 @@ +name: Build matrix + +on: + workflow_call: + outputs: + matrix: + value: ${{ jobs.setup-matrix.outputs.matrix }} + +jobs: + # IMPORTANT: in case of changing the structure of this file make sure to test + # the changes against `npm/gen-root.ts` file + setup-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.setup-matrix.outputs.matrix }} + steps: + - id: setup-matrix + uses: druzsan/setup-matrix@v2 + with: + matrix: | + build: + [ + linux-x64-gnu, + linux-x64-musl, + linux-arm64-gnu, + linux-arm64-musl, + linux-ia32-gnu, + darwin-arm64, + darwin-x64, + win32-x64-msvc, + win32-arm64-msvc, + win32-ia32-msvc, + ] + include: + - build: linux-x64-gnu + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-gnu + libc: glibc + + - build: linux-x64-musl + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-musl + libc: musl + cross: true + + - build: linux-arm64-gnu + os: ubuntu-latest + rust: stable + target: aarch64-unknown-linux-gnu + libc: glibc + cross: true + + - build: linux-arm64-musl + os: ubuntu-latest + rust: stable + target: aarch64-unknown-linux-musl + libc: musl + cross: true + + - build: linux-ia32-gnu + os: ubuntu-latest + rust: stable + target: i686-unknown-linux-gnu + libc: glibc + cross: true + + - build: darwin-arm64 + os: macos-latest + rust: stable + target: aarch64-apple-darwin + + - build: darwin-x64 + os: macos-latest + rust: stable + target: x86_64-apple-darwin + + - build: win32-x64-msvc + os: windows-latest + rust: stable + target: x86_64-pc-windows-msvc + libc: msvc + ext: ".exe" + + - build: win32-arm64-msvc + os: windows-latest + rust: stable + target: aarch64-pc-windows-msvc + libc: msvc + ext: ".exe" + test: false + + - build: win32-ia32-msvc + os: windows-latest + rust: stable + target: i686-pc-windows-msvc + libc: msvc + ext: ".exe" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..51a59ff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +name: Build + +on: + push: + branches: + - main + pull_request: + branches: [main] + types: [opened, reopened, synchronize] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + # TODO: cancel in progress is not ok for a release since it can be cancelled in a middle of updates + # and we can end up with partial release. + # but for pull-requests cancelling previously running jobs could be beneficial + # cancel-in-progress: true + +jobs: + setup_build_matrix: + name: Outputs matrix used for cross compilation + uses: ./.github/workflows/build_matrix.yml + + test_wasm: + name: Run Tests (WASM) + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./tailcall-wasm + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: wasm32-unknown-unknown + + - name: Install Wasm Pack + run: cargo install wasm-bindgen-cli --vers "0.2.92" + + - name: Test WASM + run: | + # TODO: add test for wasm, so we could actually test that. + cargo install -q worker-build && worker-build + + test: + name: Run Tests on ${{ matrix.build }} + runs-on: ${{ matrix.os || 'ubuntu-latest' }} + needs: setup_build_matrix + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.setup_build_matrix.outputs.matrix) }} + + steps: + - uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.11.0" + + - name: Install Rust Toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install Cross compilation toolchain + uses: taiki-e/setup-cross-toolchain-action@v1 + with: + target: ${{ matrix.target }} + - uses: taiki-e/install-action@cargo-llvm-cov + + - name: Run Cargo Test + if: matrix.test != 'false' + # TODO: run llvm-cov only for single build since other builds are not sent to codecov anyway + run: cargo llvm-cov --workspace ${{ matrix.features }} --lcov --target ${{ matrix.target }} --output-path lcov.info