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

Switch to GitHub Actions #2553

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
139 changes: 139 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: CI
on: [push, pull_request]
jobs:
lint:
name: Lint source files
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-

- name: Install Dependencies
run: npm ci

- name: Lint Prettier
run: npm run prettier:check

- name: Lint ESLint
run: npm run lint

- name: Lint Flow
run: npm run check

- name: Cache TS versions
uses: actions/cache@v1
with:
path: ~/.dts
key: ${{ runner.OS }}-dts-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-dts-

- name: Lint TS typings
run: npm run check:ts

- name: Spellcheck
run: npm run check:spelling

- name: Build package
run: npm run build

coverage:
name: Measure test coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-

- name: Install Dependencies
run: npm ci

- name: Run tests and measure code coverage
run: npm run testonly:cover

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage/tests/coverage-final.json
fail_ci_if_error: true

test:
name: Run tests on Node v${{ matrix.node_version }}
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [10, 12, 13, 14]
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js v${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}

- name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-

- name: Install Dependencies
run: npm ci

- name: Run Tests
run: npm run testonly

deploy-to-npm-branch:
name: Deploy to `npm` branch
runs-on: ubuntu-latest
if: github.event == 'push' && github.repository == 'graphql/graphql-js' && github.ref == 'master'
needs: [test, lint]
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-

- name: Install Dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Deploy to `npm` branch
run: npm run gitpublish
env:
GH_TOKEN: ${{ secrets.GH_NPM_BRANCH_PUBLISH_TOKEN }}
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.

[![npm version](https://badge.fury.io/js/graphql.svg)](https://badge.fury.io/js/graphql)
[![Build Status](https://travis-ci.org/graphql/graphql-js.svg?branch=master)](https://travis-ci.org/graphql/graphql-js?branch=master)
[![Build Status](https://github.com/graphql/graphql-js/workflows/CI/badge.svg?branch=master)](https://github.com/graphql/graphql-js/actions?query=branch%3Amaster)
[![Coverage Status](https://codecov.io/gh/graphql/graphql-js/branch/master/graph/badge.svg)](https://codecov.io/gh/graphql/graphql-js)

See more complete documentation at https://graphql.org/ and
Expand Down
10 changes: 6 additions & 4 deletions resources/gitpublish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ trap "exit 1" ERR
# "graphql": "git://github.com/graphql/graphql-js.git#npm"
#

# Build
npm run build
if [ ! -d "./dist" ]; then
echo 'Directory `dist` does not exist, please run `npm run build`!'
exit 1;
fi;

# Create empty npm directory
rm -rf npm
Expand All @@ -29,8 +31,8 @@ echo $HEADREV

# Deploy
cd npm
git config user.name "Travis CI"
git config user.email "[email protected]"
git config user.name "GitHub Action Script"
git config user.email "[email protected]"
git add -A .
if git diff --staged --quiet; then
echo "Nothing to publish"
Expand Down