run tests on creating a Pull request

This commit is contained in:
cwanjau 2024-04-24 20:23:23 +03:00
Родитель befe6ea1c9
Коммит 3c3e08e841
5 изменённых файлов: 56 добавлений и 15 удалений

Просмотреть файл

@ -29,13 +29,22 @@
"spaced-comment": ["error", "always", { "markers": ["/"] }],
"space-infix-ops": ["error"],
"use-isnan": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": [
"warn",
{ "allowExpressions": true, "allowTypedFunctionExpressions": true }
],
"@typescript-eslint/interface-name-prefix": ["error", "never"],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": ["PascalCase"]
},
{
"selector": "class",
"format": ["PascalCase"]
}
],
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-use-before-define": "off",

32
.github/workflows/pullRequest.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,32 @@
name: PullRequest
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: |
npm i -g @vercel/ncc
npm install
- name: Compile files
run: npm run build
- name: Run tests
run: npm run test
- name: Check linting errors
run: npm run lint

Просмотреть файл

@ -2,7 +2,7 @@
"name": "syncConfig",
"private": true,
"scripts": {
"build": "ncc build src\\main.ts -m -o lib",
"build": "ncc build src/main.ts -m -o lib",
"lint": "eslint src/**/*.ts",
"lint:fix": "eslint src/**/*.ts --fix",
"test": "jest"

Просмотреть файл

@ -3,6 +3,13 @@ import * as core from '@actions/core';
import { ConfigFormat } from './configfile';
import { ArgumentError } from './errors';
/**
* Represents the tags that apply to a setting
*/
export interface Tags {
[propertyName: string]: string;
}
/**
* Represents the inputs to the GitHub action
*/
@ -20,13 +27,6 @@ export interface Input {
contentType?: string;
}
/**
* Represents the tags that apply to a setting
*/
export interface Tags {
[propertyName: string]: string;
}
/**
* Obtain the action inputs from the GitHub environment
*/

Просмотреть файл

@ -9,13 +9,13 @@ describe('loadConfigFiles', () => {
it('throw when no config files are found', async () => {
const promise = configfile.loadConfigFiles(__dirname, "missing.json", configfile.ConfigFormat.JSON, ".");
await (expect(promise)).rejects.toThrowError(ArgumentError);
await (expect(promise)).rejects.toThrow(ArgumentError);
})
it('throw when config format is invalid', async () => {
const promise = configfile.loadConfigFiles(__dirname, "appsettings.json", -1 as configfile.ConfigFormat, ".");
await (expect(promise)).rejects.toThrowError(ParseError);
await (expect(promise)).rejects.toThrow(ParseError);
})
it('loads JSON with separator .', async () => {
@ -43,7 +43,7 @@ describe('loadConfigFiles', () => {
it('throw when JSON is invalid', async () => {
const promise = configfile.loadConfigFiles(__dirname, "invalid.json", configfile.ConfigFormat.JSON, ".");
await (expect(promise)).rejects.toThrowError(ParseError);
await (expect(promise)).rejects.toThrow(ParseError);
})
it('loads YAML', async () => {
@ -62,9 +62,9 @@ describe('loadConfigFiles', () => {
})
it('throw when YAML is invalid', async () => {
const promise = configfile.loadConfigFiles(__dirname, "invalid.YAML", configfile.ConfigFormat.YAML, ".");
const promise = configfile.loadConfigFiles(__dirname, "invalid.yaml", configfile.ConfigFormat.YAML, ".");
await (expect(promise)).rejects.toThrowError(ParseError);
await (expect(promise)).rejects.toThrow(ParseError);
})
it('loads .properties', async () => {