Skip to content

Commit

Permalink
ci: simplify pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jan 5, 2024
1 parent 7b94a84 commit 106717e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 104 deletions.
158 changes: 55 additions & 103 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,136 +3,88 @@
name: CI
on: [push, pull_request]
jobs:
build:
name: build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Fetch deps
run: yarn

- name: Build target
run: yarn build

- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: artifact-${{ github.run_id }}
retention-days: 1
path: |
docs
target
flow-typed
typings
buildstamp.json
package.json
test_push:
needs: build
push:
name: Push ${{ github.ref }}
if: github.event_name == 'push'
runs-on: ubuntu-22.04
permissions:
checks: read
statuses: write
contents: write
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Restore artifact
uses: actions/download-artifact@v3
uses: actions/checkout@v4
with:
name: artifact-${{ github.run_id }}
fetch-depth: ${{ github.ref == 'refs/heads/master' && '0' || '1' }}

- uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
# cache: 'yarn'

- name: Yarn install
- name: Install deps
run: |
sudo apt-get install -y moreutils
yarn
- name: Unit tests
- name: Build
run: yarn build

- name: Run tests
run: yarn test

- name: Update coverage
- name: Codeclimate
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
uses: paambaati/codeclimate-action@v5.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
name: artifact-${{ github.run_id }}
retention-days: 1
path: |
coverage
.nyc_output
coverageLocations: |
${{github.workspace}}/coverage/lcov.info:lcov
test_pr:
- name: Semantic Release
if: github.ref == 'refs/heads/master'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_PROVENANCE: true
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
run: npm_config_yes=true npx zx-semrel

pr:
if: github.event_name == 'pull_request'
needs: build
name: PR (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
strategy:
matrix:
os: [ ubuntu-22.04 ]
node-version: [ 16, 18, 20 ]
name: Test (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
node-version: [ 16, 20 ]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Restore artifact
uses: actions/download-artifact@v3
with:
name: artifact-${{ github.run_id }}
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- name: Test only
if: matrix.node-version != '18' || matrix.os != 'ubuntu-22.04'
run: yarn test

- name: Test & push coverage
if: matrix.node-version == '18' && matrix.os == 'ubuntu-22.04'
run: yarn test

release:
name: Release
# https://gh.neting.ccmunity/t/trigger-job-on-tag-push-only/18076
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: test_push
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Restore artifact
uses: actions/download-artifact@v3
with:
name: artifact-${{ github.run_id }}
- name: Install deps
run: |
sudo apt-get install -y moreutils
yarn
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Build
run: yarn build

- name: Codeclimate
uses: paambaati/codeclimate-action@v5.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/coverage/lcov.info:lcov
- name: Unit test only
if: matrix.node-version != '20' || matrix.os != 'ubuntu-22.04'
run: yarn test:unit

- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_COMMITTER_EMAIL: 'opensource@qiwi.com'
GIT_COMMITTER_NAME: 'qiwibot'
run: npm_config_yes=true npx zx-semrel
- name: Full test suite
if: matrix.node-version == '20' && matrix.os == 'ubuntu-22.04'
run: yarn test
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"type": "module",
"exports": {
"import": "./target/es6/index.mjs",
"require": "./target/es5/index.js"
"require": "./target/es5/index.js",
"types": "./typings/index.d.ts"
},
"main": "target/bundle/license.cjs",
"module": "target/bundle/license.mjs",
Expand Down

0 comments on commit 106717e

Please sign in to comment.