Skip to content

Commit

Permalink
feat(core): migrate to rust
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Nov 1, 2024
1 parent 35dea02 commit a37e52e
Show file tree
Hide file tree
Showing 462 changed files with 39,190 additions and 20,770 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
Empty file added .env
Empty file.
10 changes: 10 additions & 0 deletions .env.darwin-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NAME=darwin-arm64
NODE_ARCH=arm64
NODE_OS=darwin
NODE_PKG_NAME=syncpack-darwin-arm64
OS=macos-13
TARGET=aarch64-apple-darwin
RUST_BINARY_PATH="target/${TARGET}/release/syncpack"
NODE_PKG_DIR_PATH="npm/packages/${NODE_PKG_NAME}"
NODE_PKG_RUST_BINARY_PATH="${NODE_PKG_DIR_PATH}/bin/syncpack"
NODE_ROOT_PKG_DIR_PATH=npm/packages/syncpack
10 changes: 10 additions & 0 deletions .env.darwin-x64
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NAME=darwin-x64
NODE_ARCH=x64
NODE_OS=darwin
NODE_PKG_NAME=syncpack-darwin-x64
OS=macos-13
TARGET=x86_64-apple-darwin
RUST_BINARY_PATH="target/${TARGET}/release/syncpack"
NODE_PKG_DIR_PATH="npm/packages/${NODE_PKG_NAME}"
NODE_PKG_RUST_BINARY_PATH="${NODE_PKG_DIR_PATH}/bin/syncpack"
NODE_ROOT_PKG_DIR_PATH=npm/packages/syncpack
10 changes: 10 additions & 0 deletions .env.linux-arm64-glibc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NAME=linux-arm64-glibc
NODE_ARCH=arm64
NODE_OS=linux
NODE_PKG_NAME=syncpack-linux-arm64
OS=ubuntu-22.04
TARGET=aarch64-unknown-linux-gnu
RUST_BINARY_PATH="target/${TARGET}/release/syncpack"
NODE_PKG_DIR_PATH="npm/packages/${NODE_PKG_NAME}"
NODE_PKG_RUST_BINARY_PATH="${NODE_PKG_DIR_PATH}/bin/syncpack"
NODE_ROOT_PKG_DIR_PATH=npm/packages/syncpack
10 changes: 10 additions & 0 deletions .env.linux-x64-glibc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NAME=linux-x64-glibc
NODE_ARCH=x64
NODE_OS=linux
NODE_PKG_NAME=syncpack-linux-x64
OS=ubuntu-22.04
TARGET=x86_64-unknown-linux-gnu
RUST_BINARY_PATH="target/${TARGET}/release/syncpack"
NODE_PKG_DIR_PATH="npm/packages/${NODE_PKG_NAME}"
NODE_PKG_RUST_BINARY_PATH="${NODE_PKG_DIR_PATH}/bin/syncpack"
NODE_ROOT_PKG_DIR_PATH=npm/packages/syncpack
10 changes: 10 additions & 0 deletions .env.win32-arm64-msvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NAME=win32-arm64-msvc
NODE_ARCH=arm64
NODE_OS=win32
NODE_PKG_NAME=syncpack-windows-arm64
OS=windows-2022
TARGET=aarch64-pc-windows-msvc
RUST_BINARY_PATH="target/${TARGET}/release/syncpack"
NODE_PKG_DIR_PATH="npm/packages/${NODE_PKG_NAME}"
NODE_PKG_RUST_BINARY_PATH="${NODE_PKG_DIR_PATH}/bin/syncpack"
NODE_ROOT_PKG_DIR_PATH=npm/packages/syncpack
10 changes: 10 additions & 0 deletions .env.win32-x64-msvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NAME=win32-x64-msvc
NODE_ARCH=x64
NODE_OS=win32
NODE_PKG_NAME=syncpack-windows-x64
OS=windows-2022
TARGET=x86_64-pc-windows-msvc
RUST_BINARY_PATH="target/${TARGET}/release/syncpack"
NODE_PKG_DIR_PATH="npm/packages/${NODE_PKG_NAME}"
NODE_PKG_RUST_BINARY_PATH="${NODE_PKG_DIR_PATH}/bin/syncpack"
NODE_ROOT_PKG_DIR_PATH=npm/packages/syncpack
71 changes: 29 additions & 42 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,38 @@
name: verify
name: Verify v14-alpha

on:
pull_request:
branches:
- v14-alpha
push:
branches:
- v14-alpha

jobs:
all:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [18.18.0, 20.x, 22.x]

lint-and-test:
name: Lint and test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Checkout
uses: actions/checkout@v4
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
- name: Install just
uses: extractions/setup-just@v1
with:
cache: 'pnpm'
node-version: ${{ matrix.node-version }}

- name: Install
run: pnpm install

- name: Build
run: pnpm run build
env:
FORCE_COLOR: 3
TERM: xterm-256color

- name: E2E Smoke Test
if: matrix.os == 'ubuntu-latest'
run: ./test/smoke.sh

- name: Lint
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
run: pnpm run lint
env:
FORCE_COLOR: 3
TERM: xterm-256color

- name: Test
run: pnpm run test
env:
FORCE_COLOR: 3
TERM: xterm-256color
just-version: 1.35.0
- name: Check cargo
run: just check-cargo
- name: Lint formatting
run: just check-formatting
- name: Lint clippy
run: just check-clippy
- name: Cargo test
run: just test
38 changes: 38 additions & 0 deletions .github/workflows/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"NAME": "linux-x64-glibc",
"OS": "ubuntu-22.04",
"RUN_LOCALLY": true,
"TARGET": "x86_64-unknown-linux-gnu"
},
{
"NAME": "linux-arm64-glibc",
"OS": "ubuntu-22.04",
"RUN_LOCALLY": false,
"TARGET": "aarch64-unknown-linux-gnu"
},
{
"NAME": "win32-x64-msvc",
"OS": "windows-2022",
"RUN_LOCALLY": false,
"TARGET": "x86_64-pc-windows-msvc"
},
{
"NAME": "win32-arm64-msvc",
"OS": "windows-2022",
"RUN_LOCALLY": false,
"TARGET": "aarch64-pc-windows-msvc"
},
{
"NAME": "darwin-x64",
"OS": "macos-13",
"RUN_LOCALLY": false,
"TARGET": "x86_64-apple-darwin"
},
{
"NAME": "darwin-arm64",
"OS": "macos-13",
"RUN_LOCALLY": false,
"TARGET": "aarch64-apple-darwin"
}
]
111 changes: 111 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Release v14-alpha

on:
release:
types: [published]

permissions:
contents: write

jobs:
build-matrix:
name: Build matrix
runs-on: ubuntu-latest
outputs:
build_matrix: ${{ steps.set-matrix.outputs.build_matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/workflows/matrix.json
sparse-checkout-cone-mode: false
- id: set-matrix
shell: bash
run: |
if [ "$ACT" == true ]; then
echo "build_matrix=$( cat .github/workflows/matrix.json | jq --monochrome-output --compact-output '[.[] | select(.RUN_LOCALLY)]' )" >> $GITHUB_OUTPUT
else
echo "build_matrix=$( cat .github/workflows/matrix.json | jq --monochrome-output --compact-output )" >> $GITHUB_OUTPUT
fi
publish-npm-binaries:
name: Publish npm binaries
needs: build-matrix
runs-on: ${{ matrix.build.OS }}
strategy:
fail-fast: true
matrix:
build: ${{ fromJson(needs.build-matrix.outputs.build_matrix) }}
steps:
- name: Debug workflow values
shell: bash
run: |
echo "env.ACT : ${{ env.ACT }}"
echo "matrix.build.NAME : ${{ matrix.build.NAME }}"
echo "matrix.build.OS : ${{ matrix.build.OS }}"
echo "matrix.build.RUN_LOCALLY : ${{ matrix.build.RUN_LOCALLY }}"
echo "matrix.build.TARGET : ${{ matrix.build.TARGET }}"
- name: Checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.build.TARGET }}
override: true
components: rustfmt, clippy
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
- name: Install just
uses: extractions/setup-just@v1
with:
just-version: 1.35.0
- name: Build rust binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target ${{ matrix.build.TARGET }}
use-cross: ${{ !env.ACT && matrix.build.OS == 'ubuntu-22.04' }}
- name: Publish rust binary package to npm
shell: bash
run: |
just --dotenv-filename .env.${{ matrix.build.NAME }} create-npm-binary-package
just --dotenv-filename .env.${{ matrix.build.NAME }} publish-npm-binary-package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: syncpack-${{ matrix.build.TARGET }}
path: target/${{ matrix.build.TARGET }}/release/syncpack

publish-npm-base:
name: Publish npm package
needs: publish-npm-binaries
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Install just
uses: extractions/setup-just@v1
with:
just-version: 1.35.0
- name: Publish the package
shell: bash
run: |
just --dotenv-filename .env.linux-x64-glibc create-npm-root-package
just --dotenv-filename .env.linux-x64-glibc publish-npm-root-package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
**/*.rs.bk
*.log
*.log.*
.astro/
.DS_Store
.idea
*.log
*.log.*
coverage
coverage/
dist/
node_modules/
target/

# Generated packages published to npm
npm/packages
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

16 changes: 0 additions & 16 deletions .prettierrc

This file was deleted.

16 changes: 0 additions & 16 deletions .syncpackrc.js

This file was deleted.

9 changes: 9 additions & 0 deletions .syncpackrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "dist/schema.json",
"filter": ".",
"versionGroups": [
{
"isIgnored": true
}
]
}
Loading

0 comments on commit a37e52e

Please sign in to comment.