Skip to content

Commit

Permalink
Add pages-e2e (#351)
Browse files Browse the repository at this point in the history
* Add e2e tests

* Make prettier global

* Comment out broken tests

* bump vitest and uncomment commented console.log unit tests

* Use workspace version of @cloudflare/next-on-pages

* Bump e2e test runner cli version

---------

Co-authored-by: Dario Piotrowicz <[email protected]>
  • Loading branch information
GregBrimble and dario-piotrowicz authored Jun 30, 2023
1 parent 68dd9e9 commit b151505
Show file tree
Hide file tree
Showing 53 changed files with 32,104 additions and 1,948 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = tab
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
8 changes: 6 additions & 2 deletions .github/version-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ const fs = require('fs');
const { exec } = require('child_process');

try {
const nextOnPagesPackage = JSON.parse(fs.readFileSync('./packages/next-on-pages/package.json'));
const eslintPluginPackage = JSON.parse(fs.readFileSync('./packages/eslint-plugin-next-on-pages/package.json'));
const nextOnPagesPackage = JSON.parse(
fs.readFileSync('./packages/next-on-pages/package.json')
);
const eslintPluginPackage = JSON.parse(
fs.readFileSync('./packages/eslint-plugin-next-on-pages/package.json')
);

exec('git rev-parse --short HEAD', (err, stdout) => {
if (err) {
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/lint.yml

This file was deleted.

109 changes: 109 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Pull request checks
on: [push]

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
formatting:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.13.x

- name: Install
run: npm ci

- name: Check formatting
run: npm run prettier:check
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.13.x

- name: Install
run: npm ci

- name: Check linting
run: npm run lint
types:
name: Types
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.13.x

- name: Install
run: npm ci

- name: Check types
run: npm run types-check
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.13.x

- name: Install
run: npm ci

- name: Build
run: npm run build
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.13.x

- name: Install
run: npm ci

- name: Run unit tests
run: npm run test:unit
e2e-tests:
name: e2e tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install
run: npm ci

- name: Run e2e tests
run: npm run test:e2e
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
PROJECT_NAME: ${{ vars.PROJECT_NAME }}
26 changes: 0 additions & 26 deletions .github/workflows/tests.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,7 @@ dist

# Turobrepo
.turbo/

# pages-e2e
/pages-e2e/workspaces
/pages-e2e/test-workspaces
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"json.schemas": [
{
"fileMatch": ["main.fixture"],
"url": "./node_modules/@cfpreview/pages-e2e-test-runner-cli/schemas/fixture-schema.jsonc"
},
{
"fileMatch": ["main.feature"],
"url": "./node_modules/@cfpreview/pages-e2e-test-runner-cli/schemas/fixture-schema.jsonc"
}
],
"files.associations": {
"main.fixture": "jsonc",
"main.feature": "jsonc"
}
}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
Alongside the `@cloudflare/next-on-pages` there is an additional package `eslint-plugin-next-on-pages` implementing an Eslint plugin which aim is to aid developers at using the `@cloudflare/next-on-pages` more efficiently and improve their overall developer experience when working with it.

You can see the packages contents (with their documentation) in their respective package directories:
- [`@cloudflare/next-on-pages`](https://github.com/cloudflare/next-on-pages/tree/main/packages/next-on-pages#cloudflarenext-on-pages)
- [`eslint-plugin-next-on-pages`](https://github.com/cloudflare/next-on-pages/tree/main/packages/eslint-plugin-next-on-pages#eslint-plugin-next-on-pages)

- [`@cloudflare/next-on-pages`](https://github.com/cloudflare/next-on-pages/tree/main/packages/next-on-pages#cloudflarenext-on-pages)
- [`eslint-plugin-next-on-pages`](https://github.com/cloudflare/next-on-pages/tree/main/packages/eslint-plugin-next-on-pages#eslint-plugin-next-on-pages)

## Contributing

Expand Down
44 changes: 22 additions & 22 deletions internal-packages/eslint-config-next-on-pages/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
module.exports = {
env: {
es2021: true,
node: true
node: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [],
parser: "@typescript-eslint/parser",
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: "module",
project: true
sourceType: 'module',
project: true,
},
plugins: ["@typescript-eslint", "deprecation"],
plugins: ['@typescript-eslint', 'deprecation'],
rules: {
"no-case-declarations": "error",
"no-console": "error",
"prefer-const": "error",
"no-mixed-spaces-and-tabs": "off", // off because it conflicts with prettier
"eqeqeq": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/consistent-type-imports": "error",
'no-case-declarations': 'error',
'no-console': 'error',
'prefer-const': 'error',
'no-mixed-spaces-and-tabs': 'off', // off because it conflicts with prettier
eqeqeq: 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/consistent-type-imports': 'error',

// Promises & async/await
"no-async-promise-executor": "error",
"no-promise-executor-return": "error",
"no-return-await": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/promise-function-async": "error",
'no-async-promise-executor': 'error',
'no-promise-executor-return': 'error',
'no-return-await': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/promise-function-async': 'error',

"deprecation/deprecation": "error",
'deprecation/deprecation': 'error',
},
ignorePatterns: ["vitest.config.ts"]
ignorePatterns: ['vitest.config.ts'],
};
Loading

0 comments on commit b151505

Please sign in to comment.