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

Improve CI #864

Merged
merged 7 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 5 additions & 8 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node 14
- name: Use Node
uses: actions/setup-node@master
with:
node-version: 14
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
node-version: '16.8.0'
- name: Cache Yarn
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-14-yarn-${{ hashFiles('yarn.lock') }}
path: '**/node_modules'
key: ${{ runner.os }}-16.8.0-15-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-14-yarn-
${{ runner.os }}-16.8.0-15-yarn
- name: Install Dependencies using Yarn
run: yarn install
- name: Build
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ jobs:
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Yarn
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-14-yarn-${{ hashFiles('yarn.lock') }}
path: '**/node_modules'
key: ${{ runner.os }}-16.8.0-15-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-14-yarn-
${{ runner.os }}-16.8.0-15-yarn
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Release Canary
Expand Down
55 changes: 0 additions & 55 deletions .github/workflows/main.yml

This file was deleted.

11 changes: 4 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,18 @@ jobs:
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: '16.8.0'
- name: Setup NPM credentials
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Yarn
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-14-15-yarn-${{ hashFiles('yarn.lock') }}
path: '**/node_modules'
key: ${{ runner.os }}-16.8.0-15-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-14-15-yarn-
${{ runner.os }}-16.8.0-15-yarn
- name: Install Dependencies using Yarn
run: yarn install && git checkout yarn.lock
- name: Create Release Pull Request or Publish to npm
Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Tests

on:
push:
branches:
- master
pull_request: {}

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: '16.8.0'
Copy link
Collaborator

Choose a reason for hiding this comment

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

why 16.8.0 in specific when 16.12.0 is already out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't sure if this bug has been fixed;
nodejs/node#40030

- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-16.8.0-15-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-16.8.0-15-yarn
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Lint
run: yarn lint
build:
name: Type Check on GraphQL v${{matrix.graphql_version}}
runs-on: ubuntu-latest
strategy:
matrix:
graphql_version:
# - 14
- 15
# - 16.0.0-rc.1
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: '16.8.0'
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-16.8.0-${{matrix.graphql_version}}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-16.8.0-${{matrix.graphql_version}}-yarn
- name: Use GraphQL v${{matrix.graphql_version}}
run: node ./scripts/match-graphql.js ${{matrix.graphql_version}}
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Build
run: yarn ts:check
test:
name: Unit Test on Node ${{matrix.node-version}} (${{matrix.os}}) and GraphQL v${{matrix.graphql_version}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest] # remove windows to speed up the tests
node-version: [12, '16.8.0']
graphql_version:
# - 14
- 15
# - 16.0.0-rc.1
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-yarn
- name: Use GraphQL v${{matrix.graphql_version}}
run: node ./scripts/match-graphql.js ${{matrix.graphql_version}}
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Cache Jest
uses: actions/cache@v2
with:
path: .cache/jest
key: ${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-jest-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-jest-
- name: Test
run: yarn test --ci
env:
CI: true
test_esm:
name: ESM Test
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: '16.8.0'
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-16.8.0-15-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-16.8.0-15-yarn
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Build Packages
run: yarn build
- name: Test ESM
run: node scripts/test-esm.mjs
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: [['@babel/preset-env', { targets: { node: process.versions.node.split('.')[0] } }], '@babel/preset-typescript'],
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }], '@babel/plugin-proposal-class-properties'],
};
25 changes: 14 additions & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const { resolve } = require('path');
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig.json');
const CI = !!process.env.CI;

const ROOT_DIR = __dirname;
const TSCONFIG = resolve(ROOT_DIR, 'tsconfig.json');
const tsconfig = require(TSCONFIG);

module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
modulePathIgnorePatterns: ["/dist/"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
globals: {
'ts-jest': {
diagnostics: false
}
},
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' })
};
rootDir: ROOT_DIR,
restoreMocks: true,
reporters: ['default'],
modulePathIgnorePatterns: ['dist', 'test-assets', 'test-files', 'fixtures'],
moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: `${ROOT_DIR}/` }),
collectCoverage: false,
cacheDirectory: resolve(ROOT_DIR, `${CI ? '' : 'node_modules/'}.cache/jest`),
};
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"postinstall": "patch-package",
"lint": "eslint --config .eslintrc.json --ext .ts .",
"prebuild": "rimraf packages/*/dist packages/plugins/*/dist",
"build": "tsc --project tsconfig.json && bob build",
"build": "tsc --project tsconfig.build.json && bob build",
"ts:check": "tsc --noEmit",
"test": "jest",
"test:ci": "jest --coverage",
"prerelease": "yarn build",
Expand All @@ -37,6 +38,11 @@
"prettier": "prettier --ignore-path .gitignore --write --list-different \"**/*.{ts,tsx,graphql,yml}\""
},
"devDependencies": {
"@babel/core": "7.15.8",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/plugin-proposal-decorators": "7.15.8",
"@babel/preset-env": "7.15.8",
"@babel/preset-typescript": "7.15.0",
"faker": "5.5.3",
"@types/k6": "0.34.3",
"prettier": "2.4.1",
Expand Down
20 changes: 20 additions & 0 deletions scripts/match-graphql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { writeFileSync } = require('fs');
const { resolve } = require('path');
const { argv, cwd } = require('process');

const pkgPath = resolve(cwd(), './package.json');

const pkg = require(pkgPath);

const version = argv[2];

pkg.resolutions = pkg.resolutions || {};
if (pkg.resolutions.graphql.startsWith(version)) {
console.info(`GraphQL v${version} already installed! Skipping.`);
}

const npmVersion = version.includes('-') ? version : `^${version}`;
pkg.resolutions.graphql = npmVersion;
pkg.devDependencies.graphql = npmVersion;

writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf8');
8 changes: 8 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"inlineSourceMap": false
},
"exclude": ["**/test/*.ts", "*.spec.ts", "**/tests", "**/test-assets", "**/test-files", "packages/testing"]
}
Loading