Skip to content

First implementation #1

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

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
41 changes: 41 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: GitHub action publish new version
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Флоу для релиза новой версии github action
Собирает новую версию action и коммитит ее в мастер

on:
workflow_dispatch:
inputs:
versionType:
type: choice
description: Version Type
required: true
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
publish:
name: Publish github action version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Install npm deps
run: npm ci

- name: Configure git
run: git config --global user.email "[email protected]" && git config --global user.name "y-infra"

- name: Bump version
run: npm version ${{ github.event.inputs.versionType }}

- name: Build github action
run: npm run ci:build

- name: Commit version
run: git add dist -f && git commit --amend --no-edit dist && git push --follow-tags
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Testplane CI
Copy link
Member Author

@KuznetsovRoman KuznetsovRoman Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тестовый флоу.

  • Тестирует юнит тестами
  • Прогоняет линтер
  • Билдит action
  • Запускает этот action на тестовом проекте
  • Выкладывает html-отчет на gh-pages
  • Оставляет комментарий со ссылкой на отчет


on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build_and_test:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Install npm deps
run: npm ci

- name: Run unit tests
run: npm run unit

- name: Run lint
run: npm run lint

- name: Build GitHub action
run: npm run ci:build

- name: Run Testplane action
id: testplane
uses: ./
with:
cwd: testplane-project-example

- name: Deploy report
if: always() && steps.testplane.outputs.html-report-path
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ steps.testplane.outputs.html-report-path }}
destination_dir: ${{ steps.testplane.outputs.html-report-path }}
keep_files: true

- name: Comment PR with link to Testplane HTML report
if: always() && steps.testplane.outputs.html-report-path
uses: thollander/actions-comment-pull-request@v3
with:
message: |
### Testplane run finisned

Testplane HTML-report is available at https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ steps.testplane.outputs.html-report-path }}
comment-tag: testplane_html_report_link
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist/dev.js
Copy link
Member Author

@KuznetsovRoman KuznetsovRoman Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Собирается с npm run build, запускается разработчиком
На самом деле, локально билдить какого-то смысла нет, кроме как "проверить, что оно собирается"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему в игноре не весь dist?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist/index.js будет билдиться и комиттиться.
Так же, как в npm registry коммитится build, так же и в github коммитится сбилженный github action
Вот пример github action (https://github.com/actions/cache), у них у всех dist коммитится в VCS, откуда же и запускается, когда разработчик пишет что-то вроде "uses: actions/cache@v4"

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.18.1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Максимальная версия, поддерживаемая github actions

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
43 changes: 43 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Testplane action'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Конфиг github action
Описывает входные и выходные параметры

description: 'GitHub action for Testplane'
runs:
using: 'node20'
main: 'dist/index.js'
inputs:
cwd:
description: 'Relative directory to run Testplane in'
required: false
default: '.'
package-manager:
description: 'Package manager, used in the project (one of "npm", "pnpm", "yarn")'
required: false
default: 'npm'
html-report-prefix:
description: 'Html-reporter report path prefix'
required: false
default: 'testplane-reports'
config-path:
description: 'Testplane custom config path'
required: false
default: ''
storybook:
description: 'If enabled, uses @testplane/storybook plugin tests'
required: false
default: ''
set:
description: 'Comma separated list of sets to test'
required: false
default: ''
browser:
description: 'Comma separated list of browsers to test'
required: false
default: ''
grep:
description: 'Grep expression to specify tests to launch'
required: false
default: ''
outputs:
html-report-path:
description: 'Path to html report, generated by html-reporter'
exit-code:
description: 'Testplane run exit code'
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
import eslintPluginPrettier from "eslint-plugin-prettier/recommended";

export default [
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
eslintPluginPrettier,
];
22 changes: 22 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Взял вот отсюда: https://nda.ya.ru/t/OvHYlqSL7BLF9p
Конфиг для esm должен быть примерно такой

"extensionsToTreatAsEsm": [
".ts"
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"preset": "ts-jest/presets/default-esm",
"testEnvironment": "node",
"testMatch": [
"**/*.test.ts"
],
"transform": {
"^.+\\.ts$": [
"ts-jest",
{
"isolatedModules": true,
"useESM": true
}
]
}
}
Loading
Loading