From 61377b1bd7659d0971d14c3f8851e29d106180c0 Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Sun, 29 Sep 2019 02:05:27 +0100 Subject: [PATCH] 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 --- .codecov.yml | 2 +- .github/workflows/main.yml | 87 ++++++++++++++++++++++++++++++++++ .nycrc | 1 - README.md | 4 +- azure-pipelines.yml | 61 ------------------------ test/config.json | 6 --- test/mocha.opts | 3 +- tools/publish-dev/index.js | 10 +--- tools/publish-dev/package.json | 2 +- tools/publish-dev/publish.js | 18 +++---- 10 files changed, 100 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 azure-pipelines.yml delete mode 100644 test/config.json diff --git a/.codecov.yml b/.codecov.yml index 800669f..a0fb6d0 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,6 +1,6 @@ codecov: ci: - - dev.azure.com + - github.com ignore: - "**/*/dist/*.js" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..7266567 --- /dev/null +++ b/.github/workflows/main.yml @@ -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 }} diff --git a/.nycrc b/.nycrc index 0300ee3..9a67560 100644 --- a/.nycrc +++ b/.nycrc @@ -1,7 +1,6 @@ { "include": [ "packages/**" ], "reporter": [ - "cobertura", "lcov", "text-summary" ] diff --git a/README.md b/README.md index ad937b5..7d8a709 100644 --- a/README.md +++ b/README.md @@ -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) -[![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) [![license](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index cc14c7c..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -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']) diff --git a/test/config.json b/test/config.json deleted file mode 100644 index b1e060a..0000000 --- a/test/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, mocha-junit-reporter", - "mochaJunitReporterReporterOptions": { - "mochaFile": "coverage/junit.xml" - } -} diff --git a/test/mocha.opts b/test/mocha.opts index 72a86bd..fcec131 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1,4 +1,3 @@ --recursive ---reporter mocha-multi-reporters ---reporter-options configFile=test/config.json +--reporter spec {packages,test}/**/*.{spec,test}.js diff --git a/tools/publish-dev/index.js b/tools/publish-dev/index.js index 1bf8202..68b8ddb 100644 --- a/tools/publish-dev/index.js +++ b/tools/publish-dev/index.js @@ -2,15 +2,9 @@ const publish = require( "./publish" ); -const { +if ( process.env.GITHUB_EVENT_NAME === "push" ) { - BUILD_REASON, - -} = process.env; - -if ( BUILD_REASON && BUILD_REASON === "PullRequest" ) { - - console.log( "Skipping publish, PR's are not published." ); + console.log( "Skipping publish because dev release's are only published on `git push`." ); process.exit( 0 ); } diff --git a/tools/publish-dev/package.json b/tools/publish-dev/package.json index 22145b7..c6f838f 100644 --- a/tools/publish-dev/package.json +++ b/tools/publish-dev/package.json @@ -1,5 +1,5 @@ { "name": "@pegjs/publish-dev", - "version": "2.0.0", + "version": "2.2.0", "private": true } diff --git a/tools/publish-dev/publish.js b/tools/publish-dev/publish.js index e4e2fd8..9292475 100644 --- a/tools/publish-dev/publish.js +++ b/tools/publish-dev/publish.js @@ -20,19 +20,12 @@ function publish( id ) { const { - GIT_BRANCH, + GITHUB_REF, + GITHUB_SHA, NPM_TOKEN, } = process.env; - let { - - GIT_COMMIT_SHA, - - } = process.env; - - if ( GIT_COMMIT_SHA === "not-found" ) GIT_COMMIT_SHA = GIT_BRANCH; - // local helpers function die( err ) { @@ -55,13 +48,14 @@ function publish( id ) { // 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 ); // update version field in `/package.json` - const GIT_COMMIT_SHORT_SHA = exec( "git rev-parse --short " + GIT_COMMIT_SHA, false ); - const dev = `${ VERSION }-${ GIT_BRANCH }.${ GIT_COMMIT_SHORT_SHA }`; + const GIT_COMMIT_SHORT_SHA = exec( "git rev-parse --short " + GITHUB_SHA, false ); + const dev = `${ VERSION }-${ GITHUB_REF }.${ GIT_COMMIT_SHORT_SHA }`; exec( `npm --no-git-tag-version -f version ${ dev }` );