Azure Pipelines -> GitHub Actions

- Update CodeCov CI provider URL
- Remove Support for Azure Pipelines
- Add support for GitHub Actions
- Stop generating redundent reports
- Update @pegjs/publish-dev
master
Futago-za Ryuu 5 years ago
parent cf022429bb
commit 61377b1bd7

@ -1,6 +1,6 @@
codecov: codecov:
ci: ci:
- dev.azure.com - github.com
ignore: ignore:
- "**/*/dist/*.js" - "**/*/dist/*.js"

@ -0,0 +1,87 @@
name: Github Actions
on: [ push, pull_request ]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Node.js
uses: actions/setup-node@master
with:
node-version: 10.x
- name: Install Yarn
run: npm install --global yarn
- name: Install dependencies
run: yarn --ignore-engines
- name: Lint JavaScript files using ESLint
run: yarn lint
ci:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [ 6.x, 8.x, 10.x, 12.x ]
steps:
- uses: actions/checkout@master
- name: Install Node.js
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: npm install --global yarn
- name: Install dependencies
run: yarn --ignore-engines
- name: Run tests
run: yarn test
- name: Publish code coverage results
run: yarn coverage
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
cd:
name: Publish
needs: [ lint, ci ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Node.js
uses: actions/setup-node@master
with:
node-version: 10.x
- name: Install Yarn
run: npm install --global yarn
- name: Install dependencies
run: yarn --ignore-engines
- name: 'Build "pegjs/dist/*.js" files'
run: yarn build-dist
- name: Publish pegjs@dev to NPM
run: node tools/publish-dev
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

@ -1,7 +1,6 @@
{ {
"include": [ "packages/**" ], "include": [ "packages/**" ],
"reporter": [ "reporter": [
"cobertura",
"lcov", "lcov",
"text-summary" "text-summary"
] ]

@ -1,6 +1,6 @@
[![Build Status](https://dev.azure.com/pegjs/pegjs/_apis/build/status/Azure%20Pipelines?branchName=master)](https://dev.azure.com/pegjs/pegjs/_build/latest?definitionId=1?branchName=master) ![](https://github.com/pegjs/pegjs/workflows/Github%20Actions/badge.svg)
[![Codecov](https://codecov.io/gh/pegjs/pegjs/branch/master/graph/badge.svg)](https://codecov.io/gh/pegjs/pegjs) [![Codecov](https://codecov.io/gh/pegjs/pegjs/branch/master/graph/badge.svg)](https://codecov.io/gh/pegjs/pegjs)
[![Maintainability](https://api.codeclimate.com/v1/badges/2d1f0313dea3e28e191f/maintainability)](https://codeclimate.com/github/pegjs/pegjs/maintainability) [![CodeFactor](https://www.codefactor.io/repository/github/pegjs/pegjs/badge)](https://www.codefactor.io/repository/github/pegjs/pegjs)
[![forum](https://gitq.com/badge.svg)](https://gitq.com/pegjs/pegjs) [![forum](https://gitq.com/badge.svg)](https://gitq.com/pegjs/pegjs)
[![license](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT) [![license](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT)

@ -1,61 +0,0 @@
name: $(BuildID)
resources:
repositories:
- repository: apt
type: github
name: futagoza/apt
endpoint: futagoza
variables:
- group: 'env-variables'
jobs:
- template: eslint.yml@apt
parameters:
install_scope: 'yarn'
job_script: 'yarn lint'
- template: node-test.yml@apt
parameters:
npm_test: False
beforeEach:
- script: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
displayName: 'Download Code Climate Test Reporter'
afterEach:
- script: |
./cc-test-reporter before-build
yarn test 2> /dev/null
if [ $? -eq 0 ]
then
echo '"yarn test" passed, publishing to code climate.'
./cc-test-reporter after-build --exit-code 0
echo 'Publishing code coverage results to coveralls.io'
yarn coverage
exit 0
else
echo '"yarn test" failed, publishing to code climate.'
./cc-test-reporter after-build --exit-code 1
exit 1
fi
displayName: 'mocha > codeclimate & coveralls'
env:
CC_TEST_REPORTER_ID: $(CC_TEST_REPORTER_ID)
CODECOV_TOKEN: $(CODECOV_TOKEN)
publish_test_results_to_pipelines: True
publish_code_coverage_to_pipelines: True
- template: node.yml@apt
parameters:
name: 'Publish pegjs@dev'
actions:
- script: npm run build-dist
displayName: 'Build "pegjs/dist/*.js" files'
- script: node tools/publish-dev
displayName: 'Publish to NPM'
env:
NPM_TOKEN: $(NPM_CI_TOKEN)
BUILD_REASON: $(variables['Build.Reason'])

@ -1,6 +0,0 @@
{
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "coverage/junit.xml"
}
}

@ -1,4 +1,3 @@
--recursive --recursive
--reporter mocha-multi-reporters --reporter spec
--reporter-options configFile=test/config.json
{packages,test}/**/*.{spec,test}.js {packages,test}/**/*.{spec,test}.js

@ -2,15 +2,9 @@
const publish = require( "./publish" ); const publish = require( "./publish" );
const { if ( process.env.GITHUB_EVENT_NAME === "push" ) {
BUILD_REASON, console.log( "Skipping publish because dev release's are only published on `git push`." );
} = process.env;
if ( BUILD_REASON && BUILD_REASON === "PullRequest" ) {
console.log( "Skipping publish, PR's are not published." );
process.exit( 0 ); process.exit( 0 );
} }

@ -1,5 +1,5 @@
{ {
"name": "@pegjs/publish-dev", "name": "@pegjs/publish-dev",
"version": "2.0.0", "version": "2.2.0",
"private": true "private": true
} }

@ -20,19 +20,12 @@ function publish( id ) {
const { const {
GIT_BRANCH, GITHUB_REF,
GITHUB_SHA,
NPM_TOKEN, NPM_TOKEN,
} = process.env; } = process.env;
let {
GIT_COMMIT_SHA,
} = process.env;
if ( GIT_COMMIT_SHA === "not-found" ) GIT_COMMIT_SHA = GIT_BRANCH;
// local helpers // local helpers
function die( err ) { function die( err ) {
@ -55,13 +48,14 @@ function publish( id ) {
// assertions // assertions
if ( ! GIT_BRANCH ) die( "`process.env.GIT_BRANCH` is required by " + APP ); if ( ! GITHUB_REF ) die( "`process.env.GITHUB_REF` is required by " + APP );
if ( ! GITHUB_SHA ) die( "`process.env.GITHUB_SHA` is required by " + APP );
if ( ! NPM_TOKEN ) die( "`process.env.NPM_TOKEN` is required by " + APP ); if ( ! NPM_TOKEN ) die( "`process.env.NPM_TOKEN` is required by " + APP );
// update version field in `<package>/package.json` // update version field in `<package>/package.json`
const GIT_COMMIT_SHORT_SHA = exec( "git rev-parse --short " + GIT_COMMIT_SHA, false ); const GIT_COMMIT_SHORT_SHA = exec( "git rev-parse --short " + GITHUB_SHA, false );
const dev = `${ VERSION }-${ GIT_BRANCH }.${ GIT_COMMIT_SHORT_SHA }`; const dev = `${ VERSION }-${ GITHUB_REF }.${ GIT_COMMIT_SHORT_SHA }`;
exec( `npm --no-git-tag-version -f version ${ dev }` ); exec( `npm --no-git-tag-version -f version ${ dev }` );

Loading…
Cancel
Save