Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from Azure/cwanjau/RunTestOnCreatingPR
Browse files Browse the repository at this point in the history
Add workflow to run tests on creating a pull request
  • Loading branch information
ChristineWanjau authored Apr 25, 2024
2 parents befe6ea + 3c3e08e commit 9767a4d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 15 deletions.
13 changes: 11 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/pullRequest.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 7 additions & 7 deletions src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down
10 changes: 5 additions & 5 deletions tests/configfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit 9767a4d

Please sign in to comment.