Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16fa774

Browse files
authored
chore: only test changed packages (TheAlgorithms#1194)
1 parent73bf91d commit16fa774

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

‎.github/workflows/Ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
runs-on:ubuntu-latest
1313
steps:
1414
-uses:actions/checkout@v3
15+
1516
-uses:actions/setup-node@v3
1617
with:
1718
node-version:16
@@ -20,8 +21,13 @@ jobs:
2021
-name:📦 Install dependencies
2122
run:npm ci
2223

23-
-name:🧪 Run tests
24-
run:npm test
24+
-name:🧪 Run all tests
25+
if:${{ github.event_name == 'push' }}
26+
run:npm run test
27+
28+
-name:🧪 Run tests for changed files only
29+
if:${{ github.event_name == 'pull_request' }}
30+
run:npm run test-changed
2531

2632
-name:💄 Code style
2733
run:npm run style

‎.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
."$(dirname"$0")/_/husky.sh"
33

44
npm run style
5-
npm runtest
5+
npm run test-changed

‎CONTRIBUTING.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ should add unique value.
6363

6464
####Module System
6565

66-
We use the[ES Module](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) system, which bring an official, standardized module system to JavaScript.
66+
We use the[ES Module](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) system, which bring an
67+
official, standardized module system to JavaScript.
6768

6869
It roughly means you will need to use`export` and`import` statements instead of`module.exports` and`require()`.
6970

7071
####Testing
7172

7273
Be confident that your code works. When was the last time you committed a code change, your build failed, and half of
7374
your app stopped working? Mine was last week. Writing tests for our Algorithms will help us ensure the implementations
74-
areair tight even after multiple fixes and code changes.
75+
areairtight even after multiple fixes and code changes.
7576

7677
We use[Jest](https://jestjs.io/) to run unit tests on our algorithms. It provides a very readable and expressive way to
7778
structure your test code.
@@ -107,6 +108,12 @@ You can also start Jest in "watch" mode:
107108
npmtest -- --watchAll
108109
```
109110

111+
We also prepared a helper script that runs tests only for changed files:
112+
113+
```shell
114+
npm run test-changed
115+
```
116+
110117
This will run all tests and watch source and test files for changes. When a change is made, the tests will run again.
111118

112119
####Coding Style

‎Project-Euler/test/Problem044.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import{problem44}from'../Problem044.js'
22

33
describe('checking nth prime number',()=>{
4-
it('should be invalid input if number is negative',()=>{
4+
test('should be invalid input if number is negative',()=>{
55
expect(()=>problem44(-3)).toThrowError('Invalid Input')
66
})
7-
it('should be invalid input if number is 0',()=>{
7+
test('should be invalid input if number is 0',()=>{
88
expect(()=>problem44(0)).toThrowError('Invalid Input')
99
})
1010
// Project Euler Condition Check
1111
test('if the number is greater or equal to 1',()=>{
1212
expect(problem44(1)).toBe(5482660)
1313
})
1414
// Project Euler Second Value for Condition Check
15+
// FIXME skip this test for now because it runs very long and clogs up the CI & pre-commit hook
1516
test('if the number is greater or equal to 2167',()=>{
1617
expect(problem44(2167)).toBe(8476206790)
1718
})

‎package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"type":"module",
55
"description":"A repository for All algorithms implemented in Javascript (for educational purposes only)",
66
"scripts": {
7-
"test":"jest --no-cache",
7+
"test":"jest",
8+
"test-changed":"jest --onlyChanged",
89
"style":"standard",
910
"prepare":"husky install"
1011
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp