Skip to content

Commit a2159e8

Browse files
Add Windows CI (#14065)
This PR changes the GitHub action workflow for V4 to start running all unit tests and build on both Ubuntu (our current default) _and_ Windows. This is to ensure we catch issues with paths and other Windows-specific things sooner. It does, however, not replace testing on Windows.
1 parent 87c9f32 commit a2159e8

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ permissions:
1111

1212
jobs:
1313
build:
14-
runs-on: ubuntu-latest
15-
timeout-minutes: 15
16-
1714
strategy:
15+
fail-fast: false
1816
matrix:
1917
node-version: [20]
18+
runner: [ubuntu-latest, windows-latest]
19+
20+
runs-on: ${{ matrix.runner }}
21+
timeout-minutes: 15
2022

2123
steps:
2224
- uses: actions/checkout@v3
@@ -61,6 +63,8 @@ jobs:
6163

6264
- name: Lint
6365
run: pnpm run lint
66+
# Only lint on linux to avoind \r\n line ending errors
67+
if: matrix.runner == 'ubuntu-latest'
6468

6569
- name: Test
6670
run: pnpm run test

crates/oxide/tests/auto_content.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod auto_content {
3-
use std::fs;
43
use std::process::Command;
4+
use std::{fs, path};
55

66
use tailwindcss_oxide::*;
77
use tempfile::tempdir;
@@ -15,7 +15,8 @@ mod auto_content {
1515

1616
// Create the necessary files
1717
for (path, contents) in paths_with_content {
18-
let path = dir.join(path);
18+
// Ensure we use the right path seperator for the current platform
19+
let path = dir.join(path.replace("/", path::MAIN_SEPARATOR.to_string().as_str()));
1920
let parent = path.parent().unwrap();
2021
if !parent.exists() {
2122
fs::create_dir_all(parent).unwrap();
@@ -38,18 +39,25 @@ mod auto_content {
3839
let mut paths: Vec<_> = result
3940
.files
4041
.into_iter()
41-
.map(|x| x.replace(&format!("{}/", &base), ""))
42+
.map(|x| x.replace(&format!("{}{}", &base, path::MAIN_SEPARATOR), ""))
4243
.collect();
4344

4445
for glob in result.globs {
45-
paths.push(format!("{}/{}", glob.base, glob.glob));
46+
paths.push(format!(
47+
"{}{}{}",
48+
glob.base,
49+
path::MAIN_SEPARATOR,
50+
glob.glob
51+
));
4652
}
4753

4854
paths = paths
4955
.into_iter()
5056
.map(|x| {
51-
let parent_dir = format!("{}/", &base.to_string());
57+
let parent_dir = format!("{}{}", &base.to_string(), path::MAIN_SEPARATOR);
5258
x.replace(&parent_dir, "")
59+
// Normalize paths to use unix style separators
60+
.replace("\\", "/")
5361
})
5462
.collect();
5563

packages/@tailwindcss-cli/src/utils/renderer.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import path from 'path'
22
import { describe, expect, it } from 'vitest'
33
import { relative, wordWrap } from './renderer'
4+
import { normalizeWindowsSeperators } from './test-helpers'
45

56
describe('relative', () => {
67
it('should print an absolute path relative to the current working directory', () => {
7-
expect(relative(path.resolve('index.css'))).toMatchInlineSnapshot(`"./index.css"`)
8+
expect(normalizeWindowsSeperators(relative(path.resolve('index.css')))).toMatchInlineSnapshot(
9+
`"./index.css"`,
10+
)
811
})
912

1013
it('should prefer the shortest value by default', () => {
1114
// Shortest between absolute and relative paths
12-
expect(relative('index.css')).toMatchInlineSnapshot(`"index.css"`)
15+
expect(normalizeWindowsSeperators(relative('index.css'))).toMatchInlineSnapshot(`"index.css"`)
1316
})
1417

1518
it('should be possible to override the current working directory', () => {
16-
expect(relative('../utils/index.css', '..')).toMatchInlineSnapshot(`"./utils/index.css"`)
19+
expect(normalizeWindowsSeperators(relative('../utils/index.css', '..'))).toMatchInlineSnapshot(
20+
`"./utils/index.css"`,
21+
)
1722
})
1823

1924
it('should be possible to always prefer the relative path', () => {
2025
expect(
21-
relative('index.css', process.cwd(), { preferAbsoluteIfShorter: false }),
26+
normalizeWindowsSeperators(
27+
relative('index.css', process.cwd(), { preferAbsoluteIfShorter: false }),
28+
),
2229
).toMatchInlineSnapshot(`"./index.css"`)
2330
})
2431
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import path from 'node:path'
2+
3+
export function normalizeWindowsSeperators(p: string) {
4+
return path.sep === '\\' ? p.replaceAll('\\', '/') : p
5+
}

packages/@tailwindcss-postcss/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test("`@import 'tailwindcss'` is replaced with the generated CSS", async () => {
4141
})
4242
expect(result.messages).toContainEqual({
4343
type: 'dir-dependency',
44-
dir: expect.stringMatching(/example-project\/src$/g),
44+
dir: expect.stringMatching(/example-project[\/|\\]src$/g),
4545
glob: expect.stringMatching(/^\*\*\/\*/g),
4646
parent: expect.any(String),
4747
plugin: expect.any(String),

packages/tailwindcss/src/css-parser.bench.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { readFileSync } from 'node:fs'
2+
import { fileURLToPath } from 'node:url'
3+
24
import { bench } from 'vitest'
35
import * as CSS from './css-parser.ts'
46

5-
const currentFolder = new URL('..', import.meta.url).pathname
7+
const currentFolder = fileURLToPath(new URL('..', import.meta.url))
68
const cssFile = readFileSync(currentFolder + './preflight.css', 'utf-8')
79

810
bench('css-parser on preflight.css', () => {

0 commit comments

Comments
 (0)