Skip to content

Commit b280d7a

Browse files
authored
Test & CI stuff (#462)
* Test & CI stuff * Fix command * Exclude tests
1 parent 011e33d commit b280d7a

File tree

9 files changed

+1751
-1603
lines changed

9 files changed

+1751
-1603
lines changed

.github/workflows/canary.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Use Node
1919
uses: actions/setup-node@v2
2020
with:
21-
node-version: '14.x'
21+
node-version: '16.x'
2222
- name: Configure Git Credentials
2323
run: |
2424
git config --global user.email "[email protected]"
@@ -28,21 +28,20 @@ jobs:
2828
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
2929
env:
3030
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
31-
- name: Get yarn cache
32-
id: yarn-cache
33-
run: echo "::set-output name=dir::$(yarn cache dir)"
3431
- name: Cache Yarn
3532
uses: actions/cache@v2
3633
with:
37-
path: ${{ steps.yarn-cache.outputs.dir }}
38-
key: ${{ runner.os }}-14-yarn-${{ hashFiles('yarn.lock') }}
34+
path: '**/node_modules'
35+
key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
3936
restore-keys: |
40-
${{ runner.os }}-14-yarn-
37+
${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
38+
${{ runner.os }}-16-node-modules-
4139
- name: Install Dependencies using Yarn
42-
run: yarn install --ignore-engines && git checkout yarn.lock
40+
run: yarn install && git checkout yarn.lock && yarn patch-package
4341
- name: Release Canary
4442
id: canary
4543
uses: 'kamilkisiela/release-canary@master'
44+
if: github.repository == 'dotansimha/graphql-eslint'
4645
with:
4746
npm-token: ${{ secrets.NODE_AUTH_TOKEN }}
4847
npm-script: 'yarn release:canary'
@@ -53,7 +52,6 @@ jobs:
5352
with:
5453
message: |
5554
The latest changes of this PR are available as alpha in npm (based on the declared `changesets`):
56-
5755
```
5856
${{ steps.canary.outputs.changesetsPublishedPackages}}
5957
```
@@ -68,4 +66,4 @@ jobs:
6866
The latest changes of this PR are not available as alpha, since there are no linked `changesets` for this PR.
6967
bot-token: ${{ secrets.GH_API_TOKEN }}
7068
bot: 'theguild-bot'
71-
github-token: ${{ secrets.GITHUB_TOKEN }}
69+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches:
55
- master
66
jobs:
7-
publish:
7+
build:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout Master
@@ -26,23 +26,21 @@ jobs:
2626
- name: Use Node
2727
uses: actions/setup-node@v2
2828
with:
29-
node-version: '14.x'
29+
node-version: '16.x'
3030
- name: Setup NPM credentials
3131
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
3232
env:
3333
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
34-
- name: Get yarn cache
35-
id: yarn-cache
36-
run: echo "::set-output name=dir::$(yarn cache dir)"
3734
- name: Cache Yarn
3835
uses: actions/cache@v2
3936
with:
40-
path: ${{ steps.yarn-cache.outputs.dir }}
41-
key: ${{ runner.os }}-14-15-yarn-${{ hashFiles('yarn.lock') }}
37+
path: '**/node_modules'
38+
key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
4239
restore-keys: |
43-
${{ runner.os }}-14-15-yarn-
40+
${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
41+
${{ runner.os }}-16-node-modules-
4442
- name: Install Dependencies using Yarn
45-
run: yarn install && git checkout yarn.lock
43+
run: yarn install && git checkout yarn.lock && yarn patch-package
4644
- name: Create Release Pull Request or Publish to npm
4745
id: changesets
4846
uses: changesets/action@master
@@ -52,4 +50,4 @@ jobs:
5250
title: 'Upcoming Release Changes'
5351
env:
5452
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/tests.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
lint:
13+
name: Lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Master
17+
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- name: Use Node
21+
uses: actions/setup-node@master
22+
with:
23+
node-version: 16
24+
- name: Cache Yarn
25+
uses: actions/cache@v2
26+
with:
27+
path: '**/node_modules'
28+
key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
31+
${{ runner.os }}-16-node-modules-
32+
- name: Install Dependencies using Yarn
33+
run: yarn install && git checkout yarn.lock
34+
- name: Lint
35+
run: yarn lint
36+
typecheck:
37+
name: TypeScript Type Checking
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout Master
41+
uses: actions/checkout@v2
42+
with:
43+
fetch-depth: 0
44+
- name: Use Node
45+
uses: actions/setup-node@master
46+
with:
47+
node-version: 16
48+
- name: Cache Yarn
49+
uses: actions/cache@v2
50+
with:
51+
path: '**/node_modules'
52+
key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
53+
restore-keys: |
54+
${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }}
55+
${{ runner.os }}-16-node-modules-
56+
- name: Install Dependencies using Yarn
57+
run: yarn install && git checkout yarn.lock
58+
- name: Build
59+
run: yarn transpile-ts --noEmit
60+
61+
test:
62+
name: Testing on Node ${{matrix.node_version}}
63+
timeout-minutes: 60
64+
runs-on: ubuntu-latest
65+
strategy:
66+
matrix:
67+
node_version: [12, 16]
68+
steps:
69+
- name: Checkout Master
70+
uses: actions/checkout@v2
71+
with:
72+
fetch-depth: 0
73+
- name: Use Node ${{matrix.node_version}}
74+
uses: actions/setup-node@master
75+
with:
76+
node-version: ${{ matrix.node_version }}
77+
- name: Cache Yarn
78+
uses: actions/cache@v2
79+
with:
80+
path: '**/node_modules'
81+
key: ${{ runner.os }}-${{matrix.node_version}}-node-modules-${{ hashFiles('yarn.lock') }}
82+
restore-keys: |
83+
${{ runner.os }}-${{matrix.node_version}}-node-modules-${{ hashFiles('yarn.lock') }}
84+
${{ runner.os }}-${{matrix.node_version}}-node-modules-
85+
- name: Install Dependencies using Yarn
86+
run: yarn install && git checkout yarn.lock
87+
- name: Cache Jest
88+
uses: actions/cache@v2
89+
with:
90+
path: .cache/jest
91+
key: ${{ runner.os }}-${{matrix.node_version}}-jest-${{ hashFiles('yarn.lock') }}
92+
restore-keys: |
93+
${{ runner.os }}-${{matrix.node_version}}-jest-${{ hashFiles('yarn.lock') }}
94+
${{ runner.os }}-${{matrix.node_version}}-jest-
95+
- name: Test
96+
run: yarn test
97+
env:
98+
CI: true

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
3+
};

jest.config.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ const { pathsToModuleNameMapper } = require('ts-jest/utils');
22
const { compilerOptions } = require('./tsconfig.json');
33

44
module.exports = {
5-
preset: 'ts-jest',
65
testEnvironment: 'node',
76
modulePathIgnorePatterns: ["/dist/"],
87
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
9-
globals: {
10-
'ts-jest': {
11-
diagnostics: false
12-
}
13-
},
148
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' })
159
};

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@
1515
"postinstall": "patch-package",
1616
"lint": "eslint --config .eslintrc.json --ext .ts .",
1717
"prebuild": "rimraf packages/*/dist",
18-
"build": "tsc --project tsconfig.json && bob build",
18+
"transpile-ts": "tsc --project tsconfig.json",
19+
"build": "yarn transpile-ts && bob build",
1920
"postbuild": "cp -r README.md docs ./packages/plugin/dist/",
20-
"test": "jest",
21+
"test": "jest --no-watchman --forceExit",
2122
"prerelease": "yarn build",
2223
"release": "changeset publish",
2324
"release:canary": "(node scripts/canary-release.js && yarn build && yarn changeset publish --tag alpha) || echo Skipping Canary...",
2425
"prettier": "prettier --ignore-path .gitignore --write --list-different \"**/*.{ts,tsx,graphql,yml}\""
2526
},
2627
"devDependencies": {
28+
"@babel/core": "7.14.3",
29+
"@babel/preset-env": "7.14.2",
30+
"@babel/preset-typescript": "7.13.0",
2731
"json-schema-to-markdown": "1.1.1",
2832
"@types/dedent": "0.7.0",
2933
"dedent": "0.7.0",
@@ -43,11 +47,10 @@
4347
"eslint-plugin-promise": "5.1.0",
4448
"eslint-plugin-standard": "5.0.0",
4549
"eslint-config-prettier": "8.3.0",
46-
"@types/jest": "26.0.23",
47-
"ts-jest": "26.5.6",
50+
"ts-jest": "27.0.0",
4851
"rimraf": "3.0.2",
4952
"typescript": "4.2.4",
50-
"jest": "26.6.3"
53+
"jest": "27.0.1"
5154
},
5255
"resolutions": {
5356
"@changesets/git": "1.1.1"

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"include": ["packages"],
3030
"exclude": [
3131
"**/dist",
32-
"**/temp"
32+
"**/temp",
33+
"**/tests"
3334
]
3435
}

0 commit comments

Comments
 (0)