Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip chore: 🔧 try macos and windows #1480

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 10 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: CI
on:
workflow_dispatch:
push:
branches: [master]
branches: [ master ]
paths-ignore:
- '**/*.md'
pull_request:
types: [opened, synchronize]
types: [ opened, synchronize ]
paths-ignore:
- '**/*.md'

Expand Down Expand Up @@ -48,7 +48,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
script: [ "test:e2e", "test:hmr", "test:umi" ]
runs-on: ${{ matrix.os }}
if: ${{ !startsWith(github.event.head_commit.message, 'release:') && !startsWith(github.event.head_commit.message, 'ci:') && !startsWith(github.event.head_commit.message, 'docs:') }}
steps:
Expand All @@ -60,7 +61,7 @@ jobs:
uses: ./.github/actions/rustup
with:
clippy: true
save-cache: true
save-cache: true
shared-key: mako-build-${{ matrix.os }}-${{ steps.week_mark.outputs.EXPIRES_WEEK_MARK }}-${{ hashFiles('./Cargo.lock') }}
- name: Install pnpm
uses: pnpm/action-setup@v4
Expand All @@ -74,49 +75,12 @@ jobs:
- run: pnpm i
- name: Build
run: pnpm build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.os }}
path: |
./packages/mako/*.node
./packages/mako/binding.*
./packages/mako/dist
if-no-files-found: error
test_e2e:
name: E2E
needs: build
strategy:
fail-fast: false
matrix:
script: [ "test:e2e", "test:hmr", "test:umi" ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.8
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: "pnpm"
token: ${{ secrets.GH_DOTCOM_TOKEN }}
- run: |
pnpm i
pnpm playwright install chromium

- name: Download bindings
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.os }}
path: packages/mako/
- name: LS
run: ls -l ./packages/mako
- name:
run: pnpm playwright install chromium
- name: Test E2E
shell: pwsh
run: pnpm ${{ matrix.script }}

lint:
name: Clippy
runs-on: ubuntu-latest
Expand All @@ -131,7 +95,7 @@ jobs:
with:
clippy: true
shared-key: x86-cargo-test-ubuntu-latest-${{ steps.week_mark.outputs.EXPIRES_WEEK_MARK }}-${{ hashFiles('./Cargo.lock') }}

- name: Clippy
run: cargo clippy --locked -- -D warnings

Expand Down
12 changes: 12 additions & 0 deletions scripts/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function winPath(path) {
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
if (isExtendedLengthPath) {
return path;
}

return path.replace(/\\/g, '/');
}

export function winJoin(...args) {
return winPath(path.join(...args));
}
5 changes: 3 additions & 2 deletions scripts/test-e2e.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from 'node:test';
import 'zx/globals';
import { winJoin } from './path';

// node version 小于 20 时退出
const nodeVersion = process.versions.node.split('.')[0];
Expand All @@ -25,7 +26,7 @@ const dirs = fs.readdirSync(fixtures).filter((dir) => {
for (const dir of onlyDir ? [onlyDir] : dirs) {
const testFn = dir.includes('failed') && !argv.only ? test.skip : test;
await testFn(dir, async () => {
const cwd = path.join(fixtures, dir);
const cwd = winJoin(fixtures, dir);
if (argv.umi) {
if (!fs.existsSync(path.join(cwd, 'node_modules'))) {
await $`cd ${cwd} && mkdir node_modules`;
Expand All @@ -40,7 +41,7 @@ for (const dir of onlyDir ? [onlyDir] : dirs) {
} else {
try {
// run mako build
await $`${path.join(root, 'scripts', 'mako.js')} ${cwd}`;
await $`node ${path.join(root, 'scripts', 'mako.js')} ${cwd}`;
} catch (e) {
const isErrorCase = dir.split('.').includes('error');
if (isErrorCase) {
Expand Down
17 changes: 9 additions & 8 deletions scripts/test-hmr.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import getPort, { clearLockedPorts } from 'get-port';
import { chromium, devices } from 'playwright';
import waitPort from 'wait-port';
import 'zx/globals';
import { winJoin } from './path';

function skip() {}

const root = process.cwd();
const tmp = path.join(root, 'tmp', 'hmr');
const tmpPackages = path.join(root, 'tmp', 'packages');
const tmp = winJoin(root, 'tmp', 'hmr');
const tmpPackages = winJoin(root, 'tmp', 'packages');
if (!fs.existsSync(tmp)) {
fs.mkdirSync(tmp, { recursive: true });
}
Expand Down Expand Up @@ -1096,7 +1097,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render(<><App /><section>{
assert.equal(lastResult.html, '<div>App</div>', 'Initial render');
},
async () => {
const gitPath = path.join(tmp, '.git');
const gitPath = winJoin(tmp, '.git');
if (fs.existsSync(gitPath)) {
await $`rm -rf ${gitPath}`;
}
Expand Down Expand Up @@ -1151,7 +1152,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render(<><A /><section>{Ma
assert.equal(lastResult.html, '<div>A b</div>', 'Initial render');
},
async () => {
const gitPath = path.join(tmp, '.git');
const gitPath = winJoin(tmp, '.git');
if (fs.existsSync(gitPath)) {
await $`rm -rf ${gitPath}`;
}
Expand Down Expand Up @@ -1692,22 +1693,22 @@ function normalizeFiles(files, makoConfig = {}) {

function write(files) {
for (const [file, content] of Object.entries(files)) {
const p = path.join(tmp, file);
const p = winJoin(tmp, file);
fs.mkdirSync(path.dirname(p), { recursive: true });
fs.writeFileSync(p, content, 'utf-8');
}
}

function writePackage(packageName, files) {
for (const [file, content] of Object.entries(files)) {
const p = path.join(tmpPackages, packageName, file);
const p = winJoin(tmpPackages, packageName, file);
fs.mkdirSync(path.dirname(p), { recursive: true });
fs.writeFileSync(p, content, 'utf-8');
}
}

function remove(file) {
const p = path.join(tmp, file);
const p = winJoin(tmp, file);
fs.unlinkSync(p);
}

Expand All @@ -1719,7 +1720,7 @@ async function startMakoDevServer() {
assert(port === MAKO_DEV_PORT, `port ${MAKO_DEV_PORT} is not available`);
isFirstCase = false;
}
const p = $`${path.join(
const p = $`node ${winJoin(
root,
'scripts',
'mako.js',
Expand Down
Loading