Skip to content
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

initial linting and testing set up #3

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Linting and Testing
on:
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't think this will cause any issues but we are using node version lts/iron (currently 20.18.0).


- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run ESLint
run: yarn lint
test:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above


- name: Install dependencies
run: yarn install

- name: Run tests
run: yarn test
13 changes: 13 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"transform": {
"^.+\\.ts$": "ts-jest"
},
"modulePaths": ["<rootDir>/src"],
"testRegex": "tests/.*\\.tests?\\.ts$",
"moduleFileExtensions": [
"ts",
"js",
"json",
"node"
]
}
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
"version": "0.1.0",
"description": "REST API for ACM at UCSD's hackathon portal.",
"main": "index.js",
"scripts": {
"build": "tsc",
"test": "jest --config jest.config.json --runInBand",
"lint": "eslint ./ --ext .ts",
"lint:fix": "eslint ./ --ext .ts --fix"
},
"repository": "https://github.com/acmucsd/hackathon-portal.git",
"author": "Eric Chang <[email protected]>",
"dependencies": {},
"devDependencies": {
"@types/jest": "^29.5.13",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"eslint": "^8.57.1",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-plugin-import": "^2.31.0",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"typescript": "^5.6.3"
}
}
17 changes: 17 additions & 0 deletions tests/sample.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe('dummy test', () => {
test('dummy test case always passes', () => {
expect(1 + 1).toBe(2);
});
});

describe('dummy test', () => {
test('another dummy test case always passes', () => {
expect(1 + 2).toBe(3);
});
});

// describe('dummy test', () => {
// test('dummy test will fail', () => {
// expect(1 + 1).toBe(0);
// });
// });
Loading
Loading