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

build: migrate to yarn berry, up docma, migrate from travis to gh-actions #361

Merged
merged 14 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
268 changes: 268 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
# This is a Github Workflow that runs tests on any push or pull request.
# If the tests pass and this is a push to the master branch it also runs Semantic Release.
name: CI
on: [push, pull_request]

jobs:
init:
name: init
runs-on: ubuntu-22.04
outputs:
yarn-cache-dir: ${{ steps.yarn-cache-dir-path.outputs.dir }}
checksum: ${{ steps.checksum.outputs.checksum }}
steps:
- uses: actions/checkout@v3

- name: Get yarn cache dir
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Get src checksum
id: checksum
run: echo "::set-output name=checksum::${{ hashFiles('yarn.lock') }}-${{ hashFiles('packages/*/src/**/*') }}-${{ hashFiles('packages/*/*.json') }}"

build:
name: build
needs: init
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Download artifact
uses: qiwi-forks/action-download-artifact@v2
with:
name: artifact-${{ needs.init.outputs.checksum }}
workflow: 'ci.yaml'
workflow_conclusion: false
nothrow: true
search_artifacts: true
search_depth: 10

- name: Check artifact
if: always()
id: check-artifact
run: echo "::set-output name=exists::$([ -e "artifact.tar" ] && echo true || echo false)"

- uses: actions/cache@v3
if: ${{ steps.check-artifact.outputs.exists == 'false' }}
id: yarn-cache
with:
path: ${{ needs.init.outputs.yarn-cache-dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install deps
if: ${{ steps.check-artifact.outputs.exists == 'false' }}
run: yarn

- name: Build
if: ${{ steps.check-artifact.outputs.exists == 'false' }}
run: |
yarn build
tar -cvf artifact.tar packages/*/target package.json
- name: Save artifact
if: ${{ steps.check-artifact.outputs.exists == 'false' }}
uses: actions/upload-artifact@v3
with:
name: artifact-${{ needs.init.outputs.checksum }}
retention-days: 30
path: artifact.tar

# https://github.com/actions/upload-artifact/issues/53
- name: Cache artifact
uses: actions/cache@v3
id: artifact
with:
path: artifact.tar
key: artifact-${{ needs.init.outputs.checksum }}


test_push:
needs: [build, init]
if: github.event_name == 'push'
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Restore artifact from cache (if exists)
uses: actions/cache@v3
with:
path: artifact.tar
key: artifact-${{ needs.init.outputs.checksum }}

- name: Check artifact
if: always()
id: check-artifact
run: echo "::set-output name=exists::$([ -e "artifact.tar" ] && echo true || echo false)"

- name: Download artifact
if: ${{ steps.check-artifact.outputs.exists == 'false' }}
uses: qiwi-forks/action-download-artifact@v2
with:
name: artifact-${{ needs.init.outputs.checksum }}
workflow: 'ci.yaml'
workflow_conclusion: false
search_artifacts: true
search_depth: 10

- name: Unpack artifact
run: tar -xvf artifact.tar

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ needs.init.outputs.yarn-cache-dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install deps
run: yarn

- name: Test
run: yarn test

- name: Push coverage
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: artifact-${{ needs.init.outputs.checksum }}
retention-days: 1
path: |
coverage
package.json

test_pr:
if: github.event_name == 'pull_request'
needs: [build, init]
strategy:
matrix:
os: [ ubuntu-20.04 ]
node-version: [ 16 ]
name: Test (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ needs.init.outputs.yarn-cache-dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Restore artifact from cache (if exists)
uses: actions/cache@v3
with:
path: artifact.tar
key: artifact-${{ needs.init.outputs.checksum }}

- name: Check artifact
if: always()
id: check-artifact
run: echo "::set-output name=exists::$([ -e "artifact.tar" ] && echo true || echo false)"

- name: Download artifact
if: ${{ steps.check-artifact.outputs.exists == 'false' }}
uses: qiwi-forks/action-download-artifact@v2
with:
name: artifact-${{ needs.init.outputs.checksum }}
workflow: 'ci.yaml'
workflow_conclusion: false
search_artifacts: true
search_depth: 10

- name: Unpack artifact
run: tar -xvf artifact.tar

- name: Install deps
run: yarn

- name: Unit test only
if: matrix.node-version != '16' || matrix.os != 'ubuntu-20.04'
run: yarn test:unit

- name: Full test
if: matrix.node-version == '16' && matrix.os == 'ubuntu-20.04'
run: yarn test

release:
name: Release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test_push, init]
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master

- name: Restore artifact from cache (if exists)
uses: actions/cache@v3
with:
path: artifact.tar
key: artifact-${{ needs.init.outputs.checksum }}

- name: Check artifact
if: always()
id: check-artifact
run: echo "::set-output name=exists::$([ -e "artifact.tar" ] && echo true || echo false)"

- name: Download artifact
if: ${{ steps.check-artifact.outputs.exists == 'false' }}
uses: qiwi-forks/action-download-artifact@v2
with:
name: artifact-${{ needs.init.outputs.checksum }}
workflow: 'ci.yaml'
workflow_conclusion: false
search_artifacts: true
search_depth: 10

- name: Unpack artifact
run: tar -xvf artifact.tar

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Codeclimate
uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/coverage/*.lcov:lcov

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ needs.init.outputs.yarn-cache-dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow pijma env preset

env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_USER: 'qiwibot'
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_EMAIL: 'opensource@qiwi.com'
GIT_COMMITTER_EMAIL: 'opensource@qiwi.com'
GIT_AUTHOR_NAME: 'QIWI Bot'
GIT_COMMITTER_NAME: 'QIWI Bot'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
run: npm_config_yes=true npx zx-bulk-release
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '41 17 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ flow-typed/npm/
*.tsbuildinfo
.tsbuildinfo
buildcache

# Yarn berry
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.npmrc
Loading