From 173553c0372e66e03bdab19e0e6c2dd44daa14a0 Mon Sep 17 00:00:00 2001 From: kxxt Date: Fri, 26 May 2023 08:55:00 +0800 Subject: [PATCH] ci: add riscv64gc-unknown-linux-gnu --- .github/workflows/linux-riscv64.yaml | 53 ++++++++++++++++++++++++++++ cli/src/api/templates/ci-template.ts | 8 +++++ cli/src/utils/ci.ts | 9 +++++ 3 files changed, 70 insertions(+) create mode 100644 .github/workflows/linux-riscv64.yaml diff --git a/.github/workflows/linux-riscv64.yaml b/.github/workflows/linux-riscv64.yaml new file mode 100644 index 00000000..8da3d411 --- /dev/null +++ b/.github/workflows/linux-riscv64.yaml @@ -0,0 +1,53 @@ +name: Linux-riscv64 + +env: + DEBUG: 'napi:*' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + name: stable - riscv64-unknown-linux-gnu - node@18 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: Install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: riscv64gc-unknown-linux-gnu + + - name: Cache cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: stable-linux-riscv64-gnu-node@18-cargo-cache + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y gcc-riscv64-linux-gnu + yarn config set --json supportedArchitectures.cpu '["current", "riscv64"]' + yarn config set supportedArchitectures.libc "glibc" + yarn install --immutable --mode=skip-build + + - name: Cross build native tests + run: yarn build:test -- --target riscv64gc-unknown-linux-gnu diff --git a/cli/src/api/templates/ci-template.ts b/cli/src/api/templates/ci-template.ts index 783aa411..ee1dfdc4 100644 --- a/cli/src/api/templates/ci-template.ts +++ b/cli/src/api/templates/ci-template.ts @@ -94,6 +94,14 @@ jobs: - host: windows-latest target: 'aarch64-pc-windows-msvc' build: yarn build --platform --target aarch64-pc-windows-msvc + - host: ubuntu-latest + target: 'riscv64gc-unknown-linux-gnu' + setup: | + sudo apt-get update + sudo apt-get install gcc-riscv64-linux-gnu -y + build: | + yarn build --platform --target riscv64gc-unknown-linux-gnu + riscv64-linux-gnu-strip *.node name: stable - \${{ matrix.settings.target }} - node@18 runs-on: \${{ matrix.settings.host }} diff --git a/cli/src/utils/ci.ts b/cli/src/utils/ci.ts index 3084bb38..d77148db 100644 --- a/cli/src/utils/ci.ts +++ b/cli/src/utils/ci.ts @@ -99,4 +99,13 @@ export const CIConfig: Partial< ], test: false, }, + 'riscv64gc-unknown-linux-gnu': { + host: 'ubuntu-latest', + build_setup: [ + 'sudo apt-get update', + 'sudo apt-get install g++-riscv64-linux-gnu gcc-riscv64-linux-gnu -y', + ], + // No official nodejs docker image for riscv64 + test: false, + }, }