Skip to content

Commit 703c39e

Browse files
authored
chore(ci): Run npm tests for PR (#433)
1 parent c8c31a6 commit 703c39e

File tree

17 files changed

+137
-77
lines changed

17 files changed

+137
-77
lines changed

.github/workflows/cargo.yml renamed to .github/workflows/CI.yml

+75-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,73 @@
1-
name: Cargo
1+
name: CI
22

33
on:
4-
- push
5-
- pull_request
4+
pull_request:
5+
types: ["opened", "reopened", "synchronize"]
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: "${{ github.event_name == 'pull_request' }}"
613

714
env:
815
RUST_LOG: debug
916
CARGO_INCREMENTAL: 0
1017
CI: "1"
1118

1219
jobs:
13-
test:
20+
npm-test:
21+
name: "Integration Test"
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup node
27+
uses: actions/setup-node@v2
28+
with:
29+
node-version: 20
30+
31+
- name: Install Rust
32+
uses: actions-rs/toolchain@v1
33+
with:
34+
profile: minimal
35+
override: true
36+
37+
- name: Configure path (windows)
38+
shell: bash
39+
if: runner.os == 'Windows'
40+
run: |
41+
echo 'C:\\npm\\prefix' >> $GITHUB_PATH
42+
43+
- uses: Swatinem/rust-cache@v2
44+
with:
45+
shared-key: "npm-test"
46+
cache-on-failure: true
47+
48+
- run: |
49+
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
50+
npm install -g corepack@latest
51+
echo "After : corepack version => $(corepack --version)"
52+
corepack enable
53+
pnpm --version
54+
pnpm i
55+
56+
- name: Install Rust
57+
uses: actions-rs/toolchain@v1
58+
with:
59+
profile: minimal
60+
61+
- name: Install wasm target
62+
shell: bash
63+
run: |
64+
rustup target add wasm32-wasip1
65+
66+
- name: Test
67+
run: |
68+
pnpm test
69+
70+
cargo-test:
1471
strategy:
1572
fail-fast: false
1673
matrix:
@@ -56,12 +113,12 @@ jobs:
56113
run: |
57114
cargo test --all --color always
58115
59-
publish:
116+
cargo-publish:
60117
name: "Publish"
61118
runs-on: ubuntu-latest
62119
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
63120
needs:
64-
- test
121+
- cargo-test
65122

66123
steps:
67124
- uses: actions/checkout@v2
@@ -86,3 +143,15 @@ jobs:
86143
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
87144
run: |
88145
cargo mono publish --no-verify
146+
147+
done:
148+
needs:
149+
- npm-test
150+
- cargo-test
151+
if: >-
152+
${{ always() }}
153+
runs-on: ubuntu-latest
154+
name: Done
155+
steps:
156+
- run: exit 1
157+
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}

.github/workflows/bump-swc_core.yml

-40
This file was deleted.

.github/workflows/npm-publish.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- ci
87

98
env:
109
RUST_LOG: debug
@@ -16,9 +15,7 @@ jobs:
1615
name: Build
1716
runs-on: ubuntu-latest
1817
steps:
19-
- uses: actions/checkout@v2
20-
with:
21-
submodules: true
18+
- uses: actions/checkout@v4
2219

2320
- name: Setup node
2421
uses: actions/setup-node@v2

packages/emotion/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for emotion css-in-js library",
55
"main": "swc_plugin_emotion.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_emotion --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_emotion.wasm .",
99
"build:debug": "cargo build -p swc_plugin_emotion --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_emotion.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/formatjs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "FormatJS SWC plugin",
55
"main": "swc_plugin_formatjs.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_formatjs.wasm .",
99
"build:debug": "cargo build -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_formatjs.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/jest/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for jest",
55
"main": "swc_plugin_jest.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_jest --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_jest.wasm .",
99
"build:debug": "cargo build -p swc_plugin_jest --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_jest.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/loadable-components/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for `@loadable/components`",
55
"main": "swc_plugin_loadable_components.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_loadable_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_loadable_components.wasm .",
99
"build:debug": "cargo build -p swc_plugin_loadable_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_loadable_components.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/prefresh/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for preact refresh",
55
"main": "swc_plugin_prefresh.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_prefresh --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_prefresh.wasm .",
99
"build:debug": "cargo build -p swc_plugin_prefresh --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_prefresh.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/react-remove-properties/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for https://www.npmjs.com/package/babel-plugin-react-remove-properties",
55
"main": "swc_plugin_react_remove_properties.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_react_remove_properties --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_react_remove_properties.wasm .",
99
"build:debug": "cargo build -p swc_plugin_react_remove_properties --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_react_remove_properties.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/relay/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"main": "swc_plugin_relay.wasm",
66
"types": "./types.d.ts",
77
"scripts": {
8-
"prepack": "pnpm run build && vitest run",
8+
"prepack": "pnpm run build",
99
"build": "cargo build --release -p swc_plugin_relay --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_relay.wasm .",
1010
"build:debug": "cargo build -p swc_plugin_relay --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_relay.wasm .",
11-
"test": "pnpm run build:debug && vitest run"
11+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1212
},
1313
"homepage": "https://swc.rs",
1414
"repository": {

packages/remove-console/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for https://www.npmjs.com/package/babel-plugin-remove-console",
55
"main": "swc_plugin_remove_console.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_remove_console --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_remove_console.wasm .",
99
"build:debug": "cargo build -p swc_plugin_remove_console --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_remove_console.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/styled-components/__tests__/__snapshots__/wasm.test.ts.snap

+21-3
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ const someCss = css([
99
\`background:purple;\`
1010
]);
1111
const App1 = ()=>{
12-
return /*#__PURE__*/ React.createElement(_StyledIcon, null);
12+
return /*#__PURE__*/ React.createElement(_StyledIcons, null);
1313
};
1414
const App2 = ()=>{
1515
return /*#__PURE__*/ React.createElement(_StyledIconsFoo, null);
1616
};
1717
const App3 = ()=>{
1818
return /*#__PURE__*/ React.createElement(_StyledIconsFooBar, null);
1919
};
20-
var _StyledIcon = _styled(Icons).withConfig({
21-
displayName: "test___StyledIcon",
20+
var _StyledIcons = _styled(Icons).withConfig({
21+
displayName: "test___StyledIcons",
2222
componentId: "sc-d2582aa7-0"
2323
})([
2424
\`\`,
@@ -90,6 +90,24 @@ var GoodName = BadName = styled.div.withConfig({
9090
"
9191
`;
9292
93+
exports[`Should load styled-components wasm plugin correctly > Should transform add-display-names-with-member-expressions correctly 1`] = `
94+
"import styled from 'styled-components';
95+
const App = {};
96+
App.Foo = styled.div.withConfig({
97+
displayName: "test__Foo",
98+
componentId: "sc-11752c5e-0"
99+
})([
100+
\`\`
101+
]);
102+
App.Foo.Bar = styled.div.withConfig({
103+
displayName: "test__Bar",
104+
componentId: "sc-11752c5e-1"
105+
})([
106+
\`\`
107+
]);
108+
"
109+
`;
110+
93111
exports[`Should load styled-components wasm plugin correctly > Should transform add-identifier correctly 1`] = `
94112
"import styled from "styled-components";
95113
const Test = styled.div.withConfig({

packages/styled-components/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for styled-components",
55
"main": "swc_plugin_styled_components.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_styled_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_styled_components.wasm .",
99
"build:debug": "cargo build -p swc_plugin_styled_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_styled_components.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/styled-jsx/__tests__/__snapshots__/wasm.test.ts.snap

+16
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,22 @@ export { _class as default };
982982
"
983983
`;
984984
985+
exports[`Should load swc-confidential wasm plugin correctly > Should transform legacy-nesting correctly 1`] = `
986+
"import _JSXStyle from "styled-jsx/style";
987+
export default (()=>/*#__PURE__*/ React.createElement("div", {
988+
className: "jsx-3b0234e9651851cb"
989+
}, /*#__PURE__*/ React.createElement("p", {
990+
className: "jsx-3b0234e9651851cb"
991+
}, "test"), /*#__PURE__*/ React.createElement("p", {
992+
className: "jsx-3b0234e9651851cb"
993+
}, "woot"), /*#__PURE__*/ React.createElement("p", {
994+
className: "jsx-3b0234e9651851cb"
995+
}, "woot"), /*#__PURE__*/ React.createElement(_JSXStyle, {
996+
id: "3b0234e9651851cb"
997+
}, ".container.jsx-3b0234e9651851cb{color:blue;padding:3rem}.container.jsx-3b0234e9651851cb .inner.jsx-3b0234e9651851cb{color:yellow}")));
998+
"
999+
`;
1000+
9851001
exports[`Should load swc-confidential wasm plugin correctly > Should transform mixed-global-scoped correctly 1`] = `
9861002
"import _JSXStyle from "styled-jsx/style";
9871003
const Test = ()=>/*#__PURE__*/ React.createElement(_JSXStyle, {

packages/styled-jsx/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for styled-jsx",
55
"main": "swc_plugin_styled_jsx.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_styled_jsx --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_styled_jsx.wasm .",
99
"build:debug": "cargo build -p swc_plugin_styled_jsx --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_styled_jsx.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/swc-confidential/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for swc-confidential",
55
"main": "swc_plugin_swc_confidential.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_swc_confidential --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_swc_confidential.wasm .",
99
"build:debug": "cargo build -p swc_plugin_swc_confidential --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_swc_confidential.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

packages/transform-imports/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "SWC plugin for https://www.npmjs.com/package/babel-plugin-transform-imports",
55
"main": "swc_plugin_transform_imports.wasm",
66
"scripts": {
7-
"prepack": "pnpm run build && vitest run",
7+
"prepack": "pnpm run build",
88
"build": "cargo build --release -p swc_plugin_transform_imports --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_transform_imports.wasm .",
99
"build:debug": "cargo build -p swc_plugin_transform_imports --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_transform_imports.wasm .",
10-
"test": "pnpm run build:debug && vitest run"
10+
"test": "pnpm run build:debug && vitest run --testTimeout=0"
1111
},
1212
"homepage": "https://swc.rs",
1313
"repository": {

0 commit comments

Comments
 (0)