Skip to content

Commit

Permalink
chore: add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Oct 12, 2024
1 parent ee31814 commit d1d8784
Show file tree
Hide file tree
Showing 2 changed files with 173 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/build_matrix.yml
Original file line number Diff line number Diff line change
@@ -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"
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d1d8784

Please sign in to comment.