Skip to content

refactor: Merge @swc/cli into the monorepo #9

refactor: Merge @swc/cli into the monorepo

refactor: Merge @swc/cli into the monorepo #9

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
pull_request:
types: [opened, synchronize]
merge_group:
env:
CI: 1
jobs:
test:
name: Test
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16, 18, 20]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ matrix.node-version }}
- name: Test
run: pnpm test
lint:
name: Lint
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: 20
- name: Test
run: pnpm lint
cli-integration:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: yarn install
- name: Build
run: yarn build
- name: Link
run: |
yarn link
- name: (swc + spack) three.js
shell: bash
run: |
checkBuild() {
SOURCE_JS_COUNT=$(find $1 -name "*.js" | wc -l)
BUILD_JS_COUNT=$(find $2 -name "*.js" | wc -l)
echo "Compare $1 to $2"
if [[ $SOURCE_JS_COUNT -ne $BUILD_JS_COUNT ]]
then
echo "File count do not match source count: ${SOURCE_JS_COUNT} to build ${BUILD_JS_COUNT}"
exit 1
fi
}
mkdir -p integration-tests/three.js
git clone --depth 1 https://github.com/mrdoob/three.js.git integration-tests/three.js
cd integration-tests/three.js
npm install @swc/core @swc/cli --save-dev
npm install
yarn link @swc/cli
tee .swcrc <<EOF
{
"jsc": {
"target": "es2019",
"parser": {
"syntax": "ecmascript",
"dynamicImport": true
}
},
"module": {
"type": "commonjs"
}
}
EOF
echo "Run swc sync"
rm -rf build
yarn swc --sync src -d build
checkBuild "src" "build"
rm -rf build-editor
yarn swc --sync editor -d ./build-editor/
checkBuild "editor" "build-editor"
echo "Run swc async"
rm -rf build
yarn swc src -d ./build/
checkBuild "src" "build"
rm -rf build-editor
yarn swc editor -d ./build-editor/
checkBuild "editor" "build-editor"
tee spack.config.js <<EOF
module.exports = {
entry: {
web: __dirname + "/src/Three.js",
},
output: {
path: __dirname + "/out",
},
};
EOF
echo "Run spack"
yarn spack
- name: (swc + spack) rxjs
shell: bash
run: |
checkBuild() {
SOURCE_JS_COUNT=$(find $1 -name "*.ts" -o -name '*.js' | wc -l)
BUILD_JS_COUNT=$(find $2 -name "*.js" | wc -l)
echo "Compare $1 to $2"
if [[ $SOURCE_JS_COUNT -ne $BUILD_JS_COUNT ]]
then
echo "File count do not match source count: ${SOURCE_JS_COUNT} to build ${BUILD_JS_COUNT}"
exit 1
fi
}
mkdir -p integration-tests/rxjs
git clone --depth 1 https://github.com/ReactiveX/rxjs.git integration-tests/rxjs
cd integration-tests/rxjs
npm install @swc/core @swc/cli --save-dev
npm install
yarn link @swc/cli
tee .swcrc <<EOF
{
"jsc": {
"target": "es2019",
"parser": {
"syntax": "typescript",
"dynamicImport": true
}
},
"module": {
"type": "commonjs"
}
}
EOF
echo "Run swc sync"
rm -rf build
yarn swc --sync src -d build
checkBuild "src" "build"
rm -rf build-spec
yarn swc --sync spec -d build-spec
checkBuild "spec" "build-spec"
rm -rf build
echo "Run swc async"
rm -rf build
yarn swc src -d build
checkBuild "src" "build"
rm -rf build-spec
yarn swc spec -d build-spec
checkBuild "spec" "build-spec"
tee spack.config.js <<EOF
module.exports = {
entry: {
web: __dirname + "/src/index.ts",
},
output: {
path: __dirname + "/out",
},
};
EOF
echo "Run spack"
yarn spack
ci-done:
name: Ok
needs:
- test
- lint
- cli-integration
if: always()
runs-on: ubuntu-latest
steps:
- run: exit 1
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}