Skip to content

Commit

Permalink
Merge branch 'next' into th-alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnCuppens authored Dec 13, 2024
2 parents 3303879 + 4277857 commit 69e7df4
Show file tree
Hide file tree
Showing 27 changed files with 4,863 additions and 2,519 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,32 @@ jobs:
fail-fast: false
matrix:
node-version: [20]
runner: [namespace-profile-default, windows-latest, macos-14]
runner:
- name: Windows
os: windows-latest

- name: Linux
os: namespace-profile-default

- name: macOS
os: macos-14

# Exclude windows and macos from being built on feature branches
on-next-branch:
- ${{ github.ref == 'refs/heads/next' }}
exclude:
- on-next-branch: false
runner: windows-latest
runner:
name: Windows
- on-next-branch: false
runner: macos-14
runner:
name: macOS

runs-on: ${{ matrix.runner }}
runs-on: ${{ matrix.runner.os }}
timeout-minutes: 30

name: ${{ matrix.runner.name }}

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
Expand Down Expand Up @@ -72,16 +85,11 @@ jobs:
- name: Lint
run: pnpm run lint
# Only lint on linux to avoid \r\n line ending errors
if: matrix.runner == 'ubuntu-latest'
if: matrix.runner.os == 'ubuntu-latest'

- name: Test
run: pnpm run test

- name: Integration Tests
run: pnpm run test:integrations
env:
GITHUB_WORKSPACE: ${{ github.workspace }}

- name: Install Playwright Browsers
run: npx playwright install --with-deps

Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Integration Tests

on:
push:
branches: [next]
pull_request:

permissions:
contents: read

jobs:
tests:
strategy:
fail-fast: false
matrix:
node-version: [20]

runner:
- name: Windows
os: windows-latest

- name: Linux
os: namespace-profile-default

- name: macOS
os: macos-14

integration:
- upgrade
- vite
- cli
- postcss

# Exclude windows and macos from being built on feature branches
on-next-branch:
- ${{ github.ref == 'refs/heads/next' }}
exclude:
- on-next-branch: false
runner:
name: Windows
- on-next-branch: false
runner:
name: macOS

runs-on: ${{ matrix.runner.os }}
timeout-minutes: 30

name: ${{ matrix.runner.name }} / ${{ matrix.integration }}

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

# Cargo already skips downloading dependencies if they already exist
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# Cache the `oxide` Rust build
- name: Cache oxide build
uses: actions/cache@v4
with:
path: |
./target/
./crates/node/*.node
./crates/node/index.js
./crates/node/index.d.ts
key: ${{ runner.os }}-oxide-${{ hashFiles('./crates/**/*') }}

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm run build
env:
CARGO_PROFILE_RELEASE_LTO: 'off'
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: 'lld-link'

- name: Test ${{ matrix.integration }}
run: pnpm run test:integrations ./integrations/${{ matrix.integration }}
env:
GITHUB_WORKSPACE: ${{ github.workspace }}

- name: Notify Discord
if: failure() && github.ref == 'refs/heads/next'
uses: discord-actions/message@v2
with:
webhookUrl: ${{ secrets.DISCORD_WEBHOOK_URL }}
message: 'The [most recent build](<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>) on the `next` branch has failed.'
15 changes: 12 additions & 3 deletions integrations/cli/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ test(
},
},
async ({ fs, spawn }) => {
await spawn('pnpm tailwindcss --input src/index.css --output dist/out.css --watch')
let process = await spawn(
'pnpm tailwindcss --input src/index.css --output dist/out.css --watch',
)
await process.onStderr((m) => m.includes('Done in'))

await fs.expectFileToContain('dist/out.css', [
//
Expand Down Expand Up @@ -214,7 +217,10 @@ test(
},
},
async ({ fs, spawn }) => {
await spawn('pnpm tailwindcss --input src/index.css --output dist/out.css --watch')
let process = await spawn(
'pnpm tailwindcss --input src/index.css --output dist/out.css --watch',
)
await process.onStderr((m) => m.includes('Done in'))

await fs.expectFileToContain('dist/out.css', [
//
Expand Down Expand Up @@ -267,7 +273,10 @@ test(
},
},
async ({ fs, spawn }) => {
await spawn('pnpm tailwindcss --input src/index.css --output dist/out.css --watch')
let process = await spawn(
'pnpm tailwindcss --input src/index.css --output dist/out.css --watch',
)
await process.onStderr((m) => m.includes('Done in'))

await fs.expectFileToContain('dist/out.css', [
//
Expand Down
21 changes: 13 additions & 8 deletions integrations/cli/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dedent from 'dedent'
import os from 'node:os'
import path from 'node:path'
import { describe, expect } from 'vitest'
import { describe } from 'vitest'
import { candidate, css, html, js, json, test, ts, yaml } from '../utils'

const STANDALONE_BINARY = (() => {
Expand Down Expand Up @@ -156,9 +156,10 @@ describe.each([
},
},
async ({ root, fs, spawn }) => {
await spawn(`${command} --input src/index.css --output dist/out.css --watch`, {
let process = await spawn(`${command} --input src/index.css --output dist/out.css --watch`, {
cwd: path.join(root, 'project-a'),
})
await process.onStderr((m) => m.includes('Done in'))

await fs.expectFileToContain('project-a/dist/out.css', [
candidate`underline`,
Expand Down Expand Up @@ -491,7 +492,7 @@ test(
'pages/nested/foo.jsx': 'content-["pages/nested/foo.jsx"] content-["BAD"]',
},
},
async ({ fs, exec }) => {
async ({ fs, exec, expect }) => {
await exec('pnpm tailwindcss --input index.css --output dist/out.css')

expect(await fs.dumpFiles('./dist/*.css')).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -722,7 +723,7 @@ test(
></div>`,
},
},
async ({ fs, exec, spawn, root }) => {
async ({ fs, exec, spawn, root, expect }) => {
await exec('pnpm tailwindcss --input src/index.css --output dist/out.css', {
cwd: path.join(root, 'project-a'),
})
Expand Down Expand Up @@ -790,9 +791,13 @@ test(
`)

// Watch mode tests
await spawn('pnpm tailwindcss --input src/index.css --output dist/out.css --watch', {
cwd: path.join(root, 'project-a'),
})
let process = await spawn(
'pnpm tailwindcss --input src/index.css --output dist/out.css --watch',
{
cwd: path.join(root, 'project-a'),
},
)
await process.onStderr((m) => m.includes('Done in'))

// Changes to project-a should not be included in the output, we changed the
// base folder to project-b.
Expand Down Expand Up @@ -962,7 +967,7 @@ test(
'pages/nested/foo.jsx': 'content-["pages/nested/foo.jsx"] content-["BAD"]',
},
},
async ({ fs, exec }) => {
async ({ fs, exec, expect }) => {
await exec('pnpm tailwindcss --input index.css --output dist/out.css')

expect(await fs.dumpFiles('./dist/*.css')).toMatchInlineSnapshot(`
Expand Down
3 changes: 1 addition & 2 deletions integrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"private": true,
"devDependencies": {
"dedent": "1.5.3",
"fast-glob": "^3.3.2",
"kill-port": "^2.0.1"
"fast-glob": "^3.3.2"
}
}
6 changes: 4 additions & 2 deletions integrations/postcss/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ test(
},
},
async ({ fs, spawn }) => {
await spawn('pnpm postcss src/index.css --output dist/out.css --watch --verbose')
let process = await spawn('pnpm postcss src/index.css --output dist/out.css --watch --verbose')
await process.onStderr((m) => m.includes('Waiting for file changes'))

await fs.expectFileToContain('dist/out.css', [
//
Expand Down Expand Up @@ -218,7 +219,8 @@ test(
},
},
async ({ fs, spawn }) => {
await spawn('pnpm postcss src/index.css --output dist/out.css --watch --verbose')
let process = await spawn('pnpm postcss src/index.css --output dist/out.css --watch --verbose')
await process.onStderr((m) => m.includes('Waiting for file changes'))

await fs.expectFileToContain('dist/out.css', [
//
Expand Down
10 changes: 5 additions & 5 deletions integrations/postcss/core-as-postcss-plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'vitest'
import { describe } from 'vitest'
import { css, js, json, test } from '../utils'

const variantConfig = {
Expand Down Expand Up @@ -29,9 +29,9 @@ const variantConfig = {
},
}

for (let variant of Object.keys(variantConfig)) {
describe.each(Object.keys(variantConfig))('%s', (variant) => {
test(
`can not use \`tailwindcss\` as a postcss module (${variant})`,
`can not use \`tailwindcss\` as a postcss module`,
{
fs: {
...variantConfig[variant],
Expand All @@ -47,12 +47,12 @@ for (let variant of Object.keys(variantConfig)) {
'src/index.css': css`@import 'tailwindcss';`,
},
},
async ({ exec }) => {
async ({ exec, expect }) => {
expect(
exec('pnpm postcss src/index.css --output dist/out.css', undefined, { ignoreStdErr: true }),
).rejects.toThrowError(
`It looks like you're trying to use \`tailwindcss\` directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install \`@tailwindcss/postcss\` and update your PostCSS configuration.`,
)
},
)
}
})
8 changes: 3 additions & 5 deletions integrations/postcss/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import dedent from 'dedent'
import path from 'node:path'
import { expect } from 'vitest'
import { candidate, css, html, js, json, test, ts, yaml } from '../utils'

test(
Expand Down Expand Up @@ -724,7 +723,7 @@ test(
'pages/nested/foo.jsx': 'content-["pages/nested/foo.jsx"] content-["BAD"]',
},
},
async ({ fs, exec }) => {
async ({ fs, exec, expect }) => {
await exec('pnpm postcss index.css --output dist/out.css')

expect(await fs.dumpFiles('./dist/*.css')).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -954,7 +953,7 @@ test(
`,
},
},
async ({ fs, exec, spawn, root }) => {
async ({ fs, exec, spawn, root, expect }) => {
await exec('pnpm postcss src/index.css --output dist/out.css --verbose', {
cwd: path.join(root, 'project-a'),
})
Expand Down Expand Up @@ -1020,7 +1019,6 @@ test(
cwd: path.join(root, 'project-a'),
},
)

await process.onStderr((message) => message.includes('Waiting for file changes...'))

// Changes to project-a should not be included in the output, we changed the
Expand Down Expand Up @@ -1215,7 +1213,7 @@ test(
'pages/nested/foo.jsx': 'content-["pages/nested/foo.jsx"] content-["BAD"]',
},
},
async ({ fs, exec }) => {
async ({ fs, exec, expect }) => {
await exec('pnpm postcss index.css --output dist/out.css')

expect(await fs.dumpFiles('./dist/*.css')).toMatchInlineSnapshot(`
Expand Down
Loading

0 comments on commit 69e7df4

Please sign in to comment.