Skip to content

Commit

Permalink
ci: migrate to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Feb 6, 2021
1 parent 043b5ad commit eeebef1
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 109 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# 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:
build:
name: build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- run: yarn
- run: yarn build

- name: Save target
uses: actions/upload-artifact@v2
with:
name: target
retention-days: 1
path: |
docs
target
flow-typed
typings
buildstamp.json
test_fast:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Restore target
uses: actions/download-artifact@v2
with:
name: target
- uses: actions/setup-node@v2
with:
node-version: 14
- run: yarn
- name: Unit test only
run: yarn test:unit
- name: Push coverage
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v2
with:
name: target
retention-days: 1
path: coverage

test:
if: github.event_name == 'pull_request'
strategy:
matrix:
os: [ windows-2019, ubuntu-20.04 ]
node-version: [ 12, 14 ]
name: Test (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build
steps:
- uses: actions/checkout@v2
- name: Restore target
uses: actions/download-artifact@v2
with:
name: target
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- name: Intergarion test
if: matrix.node-version != '14' || matrix.os != 'ubuntu-20.04'
run: yarn test:integration
- name: Full test suite
if: matrix.node-version == '14' && matrix.os == 'ubuntu-20.04'
run: yarn test

release:
name: Release
# https://github.community/t/trigger-job-on-tag-push-only/18076
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
needs: test_fast
steps:
- uses: actions/checkout@v2
- name: Restore target
uses: actions/download-artifact@v2
with:
name: target
- uses: actions/setup-node@v2
with:
node-version: 14

- name: Codeclimate
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/coverage/*.lcov:lcov
- name: Coveralls
run: yarn push:report

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
with:
extends: |
@qiwi/semrel-config
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_EMAIL: '[email protected]'
GIT_COMMITTER_EMAIL: '[email protected]'
GIT_AUTHOR_NAME: '@antongolub'
GIT_COMMITTER_NAME: '@antongolub'
32 changes: 14 additions & 18 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
#
# 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]
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
branches: [ master ]
schedule:
- cron: '0 23 * * 2'
- cron: '23 7 * * 3'

jobs:
analyze:
Expand All @@ -22,32 +28,22 @@ jobs:
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['javascript']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
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
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
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.
# 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

Expand Down
184 changes: 93 additions & 91 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,94 @@
language: node_js
cache: yarn
node_js: 14
install: skip
os: linux
dist: focal
branch: foobarbaz

jobs:
fast_finish: true
include:
- stage: verify
if: branch != master AND type != pull_request
install: yarn
script:
- yarn build
- if [ "$CI_TEST" != "false" ]; then
yarn test;
fi
- &build
stage: build
if: branch = master
install: yarn
script: yarn build
# https://docs.travis-ci.com/user/using-workspaces/
workspaces:
create:
name: linux-shared
paths:
- target
- flow-typed
- typings
- docs
- node_modules
- <<: *build
os: windows
if: branch = master AND env(CI_WIN_BUILD) = true AND type = pull_request
# https://travis-ci.community/t/timeout-after-build-finished-and-succeeded/1336/2
env: YARN_GPG=no
workspaces:
create:
name: win-shared
paths:
- target
- node_modules

- &test
if: branch = master AND type = pull_request AND env(CI_TEST) != false
stage: test
install: skip
script: yarn test
workspaces:
use: linux-shared
- <<: *test
node_js: 12
script: yarn test:integration
- <<: *test
node_js: 15
script: yarn test:integration
- <<: *test
if: branch = master AND type != pull_request AND env(CI_TEST) != false
before_script:
- if [ "$CC_TEST_REPORTER_ID" != "" ]; then
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter;
chmod +x ./cc-test-reporter;
./cc-test-reporter before-build;
fi
script:
- if [ "$CC_TEST_REPORTER_ID" != "" ]; then
yarn test:report;
else
yarn test;
fi
after_script:
- if [ "$CC_TEST_REPORTER_ID" != "" ]; then
./cc-test-reporter format-coverage -t lcov ./coverage/lcov.info;
./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT;
fi
- <<: *test
if: branch = master AND type = pull_request AND env(CI_WIN_BUILD) = true AND env(CI_TEST) != false
os: windows
script: yarn test:integration
env: YARN_GPG=no
workspaces:
use: win-shared

- stage: release
if: branch = master AND type != pull_request AND env(CI_RELEASE) = true
workspaces:
use: linux-shared
install: skip
script: yarn release
# script: echo 'Deploy step is disabled' && exit 0
#language: node_js
#cache: yarn
#node_js: 14
#install: skip
#os: linux
#dist: focal
#
#jobs:
# fast_finish: true
# include:
# - stage: verify
# if: branch != master AND type != pull_request
# install: yarn
# script:
# - yarn build
# - if [ "$CI_TEST" != "false" ]; then
# yarn test;
# fi
# - &build
# stage: build
# if: branch = master
# install: yarn
# script: yarn build
# # https://docs.travis-ci.com/user/using-workspaces/
# workspaces:
# create:
# name: linux-shared
# paths:
# - target
# - flow-typed
# - typings
# - docs
# - node_modules
# - <<: *build
# os: windows
# if: branch = master AND env(CI_WIN_BUILD) = true AND type = pull_request
# # https://travis-ci.community/t/timeout-after-build-finished-and-succeeded/1336/2
# env: YARN_GPG=no
# workspaces:
# create:
# name: win-shared
# paths:
# - target
# - node_modules
#
# - &test
# if: branch = master AND type = pull_request AND env(CI_TEST) != false
# stage: test
# install: skip
# script: yarn test
# workspaces:
# use: linux-shared
# - <<: *test
# node_js: 12
# script: yarn test:integration
# - <<: *test
# node_js: 15
# script: yarn test:integration
# - <<: *test
# if: branch = master AND type != pull_request AND env(CI_TEST) != false
# before_script:
# - if [ "$CC_TEST_REPORTER_ID" != "" ]; then
# curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter;
# chmod +x ./cc-test-reporter;
# ./cc-test-reporter before-build;
# fi
# script:
# - if [ "$CC_TEST_REPORTER_ID" != "" ]; then
# yarn test:report;
# else
# yarn test;
# fi
# after_script:
# - if [ "$CC_TEST_REPORTER_ID" != "" ]; then
# ./cc-test-reporter format-coverage -t lcov ./coverage/lcov.info;
# ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT;
# fi
# - <<: *test
# if: branch = master AND type = pull_request AND env(CI_WIN_BUILD) = true AND env(CI_TEST) != false
# os: windows
# script: yarn test:integration
# env: YARN_GPG=no
# workspaces:
# use: win-shared
#
# - stage: release
# if: branch = master AND type != pull_request AND env(CI_RELEASE) = true
# workspaces:
# use: linux-shared
# install: skip
# script: yarn release
# # script: echo 'Deploy step is disabled' && exit 0

0 comments on commit eeebef1

Please sign in to comment.