Skip to content

Commit

Permalink
refactor: Combine actions / make e2e test runnable locally
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Feb 17, 2025
1 parent d20b664 commit 9172d0a
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 101 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/e2e-manual.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/e2e-pr.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: e2e tests

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
e2e:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js 20.11.0
uses: actions/[email protected]
with:
node-version: 20.11.0

- name: Install dependencies
run: npm ci

- name: Run e2e tests
run: npm run e2e
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ dist

# Temporary files
/tmp/
/test/tmp/
5 changes: 0 additions & 5 deletions ava-e2e-ci.config.js

This file was deleted.

1 change: 0 additions & 1 deletion ava-e2e.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import defaultAvaConfig from "./ava.config.js";

defaultAvaConfig.files = [
"test/e2e/**/*.ts",
"!test/e2e/ci-compare.ts",
];

export default defaultAvaConfig;
19 changes: 14 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ export default tseslint.config(
"test/tmp/*",
"test/projects/*",
"test/fixtures/*",
// This file must be excluded as it tests the package exports by
// requiring the package itself, which causes a circular dependency
// and TypeScript/ESlint gets confused during compilation.
"test/e2e/package-exports.ts",
"test/e2e/ci-compare.ts",

// Exclude generated code
"lib/*",
Expand Down Expand Up @@ -59,6 +54,12 @@ export default tseslint.config(
// This file is a copy of an openui5 resource which is located at
// https://github.com/SAP/openui5/blob/master/lib/jsdoc/transformApiJson.js
"src/formatter/lib/resolveLinks.ts",

// This file must be excluded as it tests the package exports by
// requiring the package itself, which causes a circular dependency
// and TypeScript/ESlint gets confused during compilation.
"test/e2e/package-exports.ts",

],
languageOptions: {
ecmaVersion: 2022,
Expand Down Expand Up @@ -129,6 +130,14 @@ export default tseslint.config(
],
"no-console": "error",
"no-eval": "error",
"ava/no-ignored-test-files": ["error", {
files: [
"test/lib/**/*.ts",
// This additional entry is needed as the rule otherwise complains about
// ignored test files. The files are configured in a separate ava config.
"test/e2e/**/*.ts",
],
}],
},
}
);
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@
"check-licenses": "licensee --errors-only",
"clean-coverage": "rimraf coverage",
"clean-lib": "rimraf lib",
"clean-test-tmp": "rimraf test/tmp",
"coverage": "npm run clean-coverage && nyc ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\"",
"depcheck": "depcheck --ignores @commitlint/config-conventional,@istanbuljs/esm-loader-hook,rimraf,sap,mycomp,@ui5/linter",
"hooks:pre-push": "npm run lint:commit",
"lint": "eslint .",
"lint:commit": "commitlint -e",
"prepare": "node ./.husky/skip.js || husky",
"test": "npm run lint && npm run build-test && npm run coverage && npm run e2e && npm run depcheck && npm run check-licenses",
"test": "npm run lint && npm run build-test && npm run coverage && npm run depcheck && npm run check-licenses",
"unit": "ava",
"e2e": "npm run build && ava --config ava-e2e.config.js",
"ci:e2e": "ava --config ava-e2e-ci.config.js",
"ci:e2e-update-snapshots": "ava --config ava-e2e-ci.config.js --update-snapshots",
"e2e": "npm run build && npm run e2e:ui5lint && npm run e2e:test",
"e2e:ui5lint": "TEST_E2E_TMP=$PWD/test/tmp/e2e && npm run clean-test-tmp && mkdir -p $TEST_E2E_TMP && cd test/fixtures/linter/projects/com.ui5.troublesome.app && ui5lint --format=json > $TEST_E2E_TMP/ui5lint-results.json 2> $TEST_E2E_TMP/stderr.log || true",
"e2e:test": "ava --config ava-e2e.config.js",
"e2e:test-update-snapshots": "ava --config ava-e2e.config.js --update-snapshots",
"unit-debug": "ava debug",
"unit-update-snapshots": "ava --update-snapshots",
"unit-watch": "ava --watch",
Expand Down
11 changes: 0 additions & 11 deletions test/e2e/ci-compare.ts

This file was deleted.

11 changes: 11 additions & 0 deletions test/e2e/compare-snapshots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import test from "ava";
import {readFile} from "node:fs/promises";

const E2E_DIR_URL = new URL("../tmp/e2e/", import.meta.url);

test.serial("Compare com.ui5.troublesome.app result snapshots", async (t) => {
const stderr = await readFile(new URL("stderr.log", E2E_DIR_URL), {encoding: "utf-8"});
t.snapshot(stderr);
const results = JSON.parse(await readFile(new URL("ui5lint-results.json", E2E_DIR_URL), {encoding: "utf-8"}));
t.snapshot(results);
});
Binary file removed test/e2e/snapshots/ci-compare.ts.snap
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Snapshot report for `test/e2e/ci-compare.ts`
# Snapshot report for `test/e2e/compare-snapshots.ts`

The actual snapshot is saved in `ci-compare.ts.snap`.
The actual snapshot is saved in `compare-snapshots.ts.snap`.

Generated by [AVA](https://avajs.dev).

## Compare snapshots
## Compare com.ui5.troublesome.app result snapshots

> Snapshot 1
''

> Snapshot 2
[
{
errorCount: 3,
Expand Down
Binary file added test/e2e/snapshots/compare-snapshots.ts.snap
Binary file not shown.

0 comments on commit 9172d0a

Please sign in to comment.