Skip to content

Commit

Permalink
Followup work on setup github actions (#7431)
Browse files Browse the repository at this point in the history
* Followup work on setup github actions

* Coverage report & split `prod_lint`

* Add env

* Remove coverage report on azure pipelines

* Remove build step on lint

* remove coverage report on prod_test

* Use `ci-info` instead of `is-ci`

* Always enable `ENABLE_TEST_RESULTS` and `AST_COMPARE` on CI

* Standalone test and remove some env

* coverage report

* reduce matrix

* standalone test

* `ci-info`

* Remove token

* Disable `coverage` on azure pipelines

* use master version of codecov-action

* Link to master status

* fix prod lint

* Use boolean env

* Remove locv report

* Try lcov report

* pin `codecov-action` version, enable `verbose`

* azure coverage

* Name

* Trigger CI

* Use `basename`

* Trigger CI

* Try `runInBand`

* try `maxWorkers`

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
  • Loading branch information
fisker and thorn0 committed Mar 23, 2020
1 parent ba500e2 commit 54f907d
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .azure-pipelines/steps/publish-code-coverage.yml
Expand Up @@ -6,6 +6,6 @@ steps:
summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml
displayName: "Publish coverage"
condition: and(variables.ENABLE_CODE_COVERAGE, succeededOrFailed())
- script: yarn codecov -f coverage/cobertura-coverage.xml
displayName: "Publish coverage to Codecov"
condition: and(variables.ENABLE_CODE_COVERAGE, succeededOrFailed())
# - script: yarn codecov -f coverage/cobertura-coverage.xml
# displayName: "Publish coverage to Codecov"
# condition: and(variables.ENABLE_CODE_COVERAGE, succeededOrFailed())
29 changes: 21 additions & 8 deletions .github/workflows/dev-test.yml
@@ -1,9 +1,9 @@
name: Dev_Test
name: Dev

on: [pull_request]
on: [push, pull_request]

jobs:
dev_test:
test:
strategy:
fail-fast: false
matrix:
Expand All @@ -15,8 +15,14 @@ jobs:
- "13"
- "12"
- "10"

name: Dev test on node ${{ matrix.node }} and ${{ matrix.os }}
include:
# only enable coverage on the fastest job
- os: "ubuntu-latest"
node: "12"
ENABLE_CODE_COVERAGE: true
env:
ENABLE_CODE_COVERAGE: ${{ matrix.ENABLE_CODE_COVERAGE }}
name: Node.js ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -27,10 +33,17 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.NODE }}
node-version: ${{ matrix.node }}

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

- name: Run Test
run: yarn test
- name: Run Tests
run: yarn test --maxWorkers=4

- name: Upload Coverage
uses: codecov/codecov-action@v1
if: matrix.ENABLE_CODE_COVERAGE
with:
file: ./coverage/lcov.info
fail_ci_if_error: true
15 changes: 9 additions & 6 deletions .github/workflows/lint.yml
@@ -1,6 +1,6 @@
name: Lint

on: [pull_request]
on: [push, pull_request]

jobs:
lint:
Expand All @@ -20,20 +20,23 @@ jobs:
- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Check dependencies
- name: Check Dependencies
run: yarn lint:deps

- name: Check JSDoc types
- name: Check JSDoc Types
run: yarn lint:typecheck

- name: Lint code
- name: Lint ESLint
run: yarn lint:eslint

- name: Lint prettier
- name: Lint Prettier
run: yarn lint:prettier

- name: Spellcheck
run: yarn lint:spellcheck

- name: Check file changes
- name: Lint Changelog
run: yarn lint:changelog

- name: Check Lock File Changes
run: yarn && echo "Listing changed files:" && git diff --name-only --exit-code && echo "No files changed during lint."
76 changes: 71 additions & 5 deletions .github/workflows/prod-test.yml
@@ -1,6 +1,6 @@
name: Prod_Test
name: Prod

on: [pull_request]
on: [push, pull_request]

jobs:
build:
Expand Down Expand Up @@ -29,7 +29,34 @@ jobs:
name: dist
path: dist

prod_test:
lint:
name: Lint
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: "12"

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

- name: Download Artifact
uses: actions/download-artifact@v1
with:
name: dist
path: dist

- name: Lint Code
run: yarn lint:dist

test:
strategy:
fail-fast: false
matrix:
Expand All @@ -41,8 +68,47 @@ jobs:
- "13"
- "12"
- "10"
name: Node.js ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

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

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

- name: Download Artifact
uses: actions/download-artifact@v1
with:
name: dist
path: dist

- name: Run Tests
run: yarn test:dist

name: Prod test on node ${{ matrix.node }} and ${{ matrix.os }}
standalone:
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-latest"
- "macos-latest"
- "windows-latest"
node:
- "13"
- "12"
- "10"
env:
STANDALONE: true
name: Node.js ${{ matrix.node }} on ${{ matrix.os }} (standalone)
runs-on: ${{ matrix.os }}
needs: [build]
steps:
Expand All @@ -65,5 +131,5 @@ jobs:
name: dist
path: dist

- name: Run Test
- name: Run Tests
run: yarn test:dist
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -39,8 +39,12 @@
<p align="center">
<a href="https://dev.azure.com/prettier/prettier/_build/latest?definitionId=5">
<img alt="Azure Pipelines Build Status" src="https://img.shields.io/azure-devops/build/prettier/79013671-677c-4846-a6d8-3050d40e21c0/5.svg?style=flat-square&label=build&branchName=master"></a>
<a href="https://github.com/prettier/prettier/actions">
<img alt="Github Actions Build Status" src="https://img.shields.io/github/workflow/status/prettier/prettier/Prod_Test?style=flat-square"></a>
<a href="https://github.com/prettier/prettier/actions?query=workflow%3AProd+branch%3Amaster">
<img alt="Github Actions Build Status" src="https://img.shields.io/github/workflow/status/prettier/prettier/Prod?label=Prod&style=flat-square"></a>
<a href="https://github.com/prettier/prettier/actions?query=workflow%3ADev+branch%3Amaster">
<img alt="Github Actions Build Status" src="https://img.shields.io/github/workflow/status/prettier/prettier/Dev?label=Dev&style=flat-square"></a>
<a href="https://github.com/prettier/prettier/actions?query=workflow%3ALint+branch%3Amaster">
<img alt="Github Actions Build Status" src="https://img.shields.io/github/workflow/status/prettier/prettier/Lint?label=Lint&style=flat-square"></a>
<a href="https://codecov.io/gh/prettier/prettier">
<img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square"></a>
<a href="https://twitter.com/acdlite/status/974390255393505280">
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Expand Up @@ -19,7 +19,7 @@ module.exports = {
"<rootDir>/src/doc/doc-debug.js",
"<rootDir>/src/main/massage-ast.js",
],
coverageReporters: ["text", "html", "cobertura"],
coverageReporters: ["text", "html", "cobertura", "lcov"],
moduleNameMapper: {
// Jest wires `fs` to `graceful-fs`, which causes a memory leak when
// `graceful-fs` does `require('fs')`.
Expand All @@ -37,4 +37,5 @@ module.exports = {
"jest-watch-typeahead/testname",
],
reporters: ["default"].concat(ENABLE_TEST_RESULTS ? "jest-junit" : []),
verbose: true,
};
3 changes: 2 additions & 1 deletion scripts/test-dist.js
Expand Up @@ -5,6 +5,7 @@
const path = require("path");
const shell = require("shelljs");
const tempy = require("tempy");
const { isCI } = require("ci-info");

shell.config.fatal = true;

Expand All @@ -20,7 +21,7 @@ shell.exec("npm init -y", { cwd: tmpDir });
shell.exec(`npm install "${tarPath}"`, { cwd: tmpDir });
shell.config.silent = false;

const runInBand = process.env.CI ? "--runInBand" : "";
const runInBand = isCI ? "--runInBand" : "";
const testPath = process.env.TEST_STANDALONE ? "tests/" : "";
const cmd = `yarn test --color ${runInBand} ${testPath}`;

Expand Down

0 comments on commit 54f907d

Please sign in to comment.