Skip to content

Commit

Permalink
ci(build-main): replace Travis by GitHub Actions
Browse files Browse the repository at this point in the history
Scripts to build, release-publish, gh-deploy have been adapted.

Removed stark-ssh key
  • Loading branch information
SuperITMan committed Mar 3, 2020
1 parent 7ad6e7d commit 1191c3f
Show file tree
Hide file tree
Showing 29 changed files with 431 additions and 463 deletions.
7 changes: 4 additions & 3 deletions .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ module.exports = {
{ value: "test", name: "test: Adding missing tests or correcting existing tests" },
{
value: "build",
name: "build: Changes that affect the build system or external dependencies (example scopes: rollup, npm)"
name: "build: Changes that affect the build system or external dependencies (example scopes: rollup, npm)"
},
{
value: "ci",
name: "ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)"
name:
"ci: Changes to our CI configuration files and scripts (example scopes: GitHub Actions, Travis, Circle, BrowserStack, SauceLabs)"
},
{
value: "chore",
name: "chore: Changes to the build process or auxiliary tools and libraries such as documentation generation"
},
{ value: "revert", name: "revert: Reverts a previous commit" }
{ value: "revert", name: "revert: Reverts a previous commit" }
],
scopes: generateScopes()
};
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ charset = utf-8
[*.bat]
end_of_line = crlf

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

[**.{css, pcss, scss,json,sh}]
[**.{css, pcss, scss, json, sh, yml}]
indent_style = space
indent_size = 2

Expand Down
222 changes: 222 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
name: ci

on:
schedule:
- cron: "0 12 * * *"
push:
branches:
- master
- /^\d+\.\d+\.\d(-alpha\.\d+|-beta\.\d+|-rc\.\d+)?$/
tags:
- "*"
pull_request:
branches:
- master

jobs:
build-test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: ["10", "12"]
os: [ubuntu-latest, macOS-latest]
env:
LOGS_DIR: /tmp/stark/logs
LOGS_FILE: /tmp/stark/logs/build-perf.log
TZ: "Europe/Brussels"
steps:
- name: Set environment variable 'IS_MAIN_ENVIRONMENT'
run: |
if [[ '${{ matrix.node_version }}' == '10' ]] && [[ '${{ matrix.os }}' == 'ubuntu-latest' ]]; then
IS_MAIN_ENVIRONMENT=1
else
IS_MAIN_ENVIRONMENT=0
fi
echo "::set-env name=IS_MAIN_ENVIRONMENT::$(echo $IS_MAIN_ENVIRONMENT)"
# See: https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v2

# See: https://github.com/marketplace/actions/setup-node-js-for-use-with-actions
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}

- name: Create file & folder for GitHub Actions logs
run: |
# cfr scripts/_ghactions-group.sh
mkdir -p $LOGS_DIR
touch $LOGS_FILE
- name: Install npm 6.9.2
run: npm i -g npm@6.9.2

- name: Get tag name if exists
id: get_tag_name
run: echo ::set-env name=GH_ACTIONS_TAG::$(echo $GITHUB_REF | sed -n "s/^refs\/tags\/\(\S*\).*$/\1/p")

- name: List main variables
run: |
echo "Commit SHA : ${GITHUB_SHA}"
echo "Reference : ${GITHUB_REF}"
echo "Repository : ${GITHUB_REPOSITORY}"
echo "Event : ${GITHUB_EVENT_NAME}"
echo "Author : ${GITHUB_ACTOR}"
echo "Main ENV : ${IS_MAIN_ENVIRONMENT}"
NODE_VERSION="$(node -v)"
echo "Node version: $NODE_VERSION"
# This ensures that we are authenticated without requiring to have an actual .npmrc file within the project
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
# See: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: |
npm ci
npm run install:ci:all
# See: https://github.com/marketplace/actions/upload-artifact
- uses: actions/upload-artifact@v1
with:
name: stark-dist
path: dist/packages-dist
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Linting and testing
run: |
npm run lint:all
npm run test:ci:all
- name: "Build showcase:ghpages"
run: npm run build:showcase:ghpages

- uses: actions/upload-artifact@v1
with:
name: showcase-dist
path: showcase/dist
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Browserstack testing
run: |
#npm run test:showcase:e2e:browserstack
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Generate docs coverage
run: npm run docs:coverage
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Save logs
run: bash ./scripts/ci/print-logs.sh

- name: Combine coveralls reports
run: node combine-packages-coverage.js
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "combined-lcov.info"
if: env.IS_MAIN_ENVIRONMENT == 1

release:
name: Release
runs-on: "ubuntu-latest"
needs: build-test
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'schedule'
env:
LOGS_DIR: /tmp/ngx-form-errors/logs
LOGS_FILE: /tmp/ngx-form-errors/logs/build-perf.log
TZ: "Europe/Brussels"
steps:
- name: Get tag name if exists
id: get_tag_name
run: echo ::set-env name=GH_ACTIONS_TAG::$(echo $GITHUB_REF | sed -n "s/^refs\/tags\/\(\S*\).*$/\1/p")

# See: https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v2

# See: https://github.com/marketplace/actions/setup-node-js-for-use-with-actions
- name: Use Node.js 10
uses: actions/setup-node@v1
with:
node-version: "10"

- name: Install npm 6.9.2
run: npm i -g npm@6.9.2

- uses: actions/download-artifact@v1
with:
name: stark-dist
path: dist/packages-dist

- uses: actions/download-artifact@v1
with:
name: showcase-dist
path: showcase/dist

# See: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Stark packages dependencies
run: |
npm ci
npm run install:ci:stark-build
npm run install:ci:stark-core
npm run install:ci:stark-rbac
npm run install:ci:stark-ui
if: github.event_name != 'schedule'

- name: Create file & folder for GitHub Actions logs
run: |
# cfr scripts/_ghactions-group.sh
mkdir -p $LOGS_DIR
touch $LOGS_FILE
- name: Generate docs
run: npm run docs:publish
env:
GH_ACTIONS_JOB_STATUS: ${{ job.status }}
if: github.event_name != 'schedule'

- name: Push docs & showcase on gh-pages
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: ".tmp/ghpages"
branch: "gp-pages"
if: github.event_name != 'schedule'

- name: Release stark
run: npm run release:publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Save logs
run: bash ./scripts/ci/print-logs.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Build
dist/
/dist/
.awcache/
dist/
.tmp/
/.tmp/
tmp/
Expand Down
62 changes: 0 additions & 62 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,62 +0,0 @@
language: node_js
node_js:
- "10"
- "12"

dist: trusty
sudo: false # better for performance

before_install:
- echo $TRAVIS_COMMIT
- echo $TRAVIS_TAG
- echo $TRAVIS_BRANCH
- echo $TRAVIS_BUILD_NUMBER
- echo $TRAVIS_REPO
- export TZ=Europe/Brussels
- npm i -g npm@6.9.2
- NODE_VERSION="$(node -v)"
- echo $NODE_VERSION
# This ensures that we are authenticated without requiring to have an actual .npmrc file within the project
- 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc'

install:
# Create file & folder for Travis logs
# cfr scripts/_travis-fold.sh
- mkdir -p $LOGS_DIR
- touch $LOGS_DIR/build-perf.log
- npm ci
- npm run install:ci:all
- npm run build:showcase:ghpages

env:
global:
- LOGS_DIR=/tmp/stark/logs
- LOGS_FILE=/tmp/stark/logs/build-perf.log

branches:
only:
- master
- /^dependabot/npm_and_yarn/.*$/
- /^\d+\.\d+\.\d(-alpha\.\d+|-beta\.\d+|-rc\.\d+)?$/

cache:
directories:
- $HOME/.npm

# Not needed since we use Puppeteer in karma.conf.ci.js
# It downloads Chrome itself and works with or without Travis
# chrome: stable

script:
- npm run lint:all
- npm run test:ci:all
# E2E tests only need to be run on 1 node version (v10)
# and the secure environmentals BROWSERSTACK_USERNAME, BROWSERSTACK_ACCESS_KEY should be set. (only on secure builds)
- if [[ ${NODE_VERSION} =~ ^v10.*$ && -n "${BROWSERSTACK_USERNAME}" && -n "${BROWSERSTACK_ACCESS_KEY}" ]]; then npm run test:showcase:e2e:browserstack; else echo "Skipping browserstack tests."; fi
- npm run docs:coverage
- npm run docs:publish
- npm run release:publish
- bash ./scripts/ci/print-logs.sh

after_success:
- npm run test:ci:coveralls:combined
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![NPM version](https://img.shields.io/npm/v/@nationalbankbelgium/stark-core.svg)](https://www.npmjs.com/package/@nationalbankbelgium/stark-core)
[![npm](https://img.shields.io/npm/dm/@nationalbankbelgium/stark-core.svg)](https://www.npmjs.com/package/@nationalbankbelgium/stark-core)
[![Build Status](https://travis-ci.org/NationalBankBelgium/stark.svg?branch=master)](https://travis-ci.org/NationalBankBelgium/stark)
[![Build Status](https://github.com/NationalBankBelgium/stark/workflows/ci/badge.svg)](https://github.com/NationalBankBelgium/stark/actions?query=workflow%3Aci)
[![Coverage Status](https://coveralls.io/repos/github/NationalBankBelgium/stark/badge.svg?branch=master)](https://coveralls.io/github/NationalBankBelgium/stark?branch=master)
[![Dependency Status](https://david-dm.org/NationalBankBelgium/stark.svg)](https://david-dm.org/NationalBankBelgium/stark)
[![devDependency Status](https://david-dm.org/NationalBankBelgium/stark/dev-status.svg)](https://david-dm.org/NationalBankBelgium/stark#info=devDependencies)
Expand Down Expand Up @@ -144,11 +144,11 @@ We're supported by [Jetbrains](https://www.jetbrains.com) and their awesome [sup

<a href="https://www.jetbrains.com"><img src="http://www.underconsideration.com/brandnew/archives/jetbrains_logo_detail.jpg" width="144px"></a>

### Travis
### GitHub Actions

We're supported by [Travis](https://travis-ci.org/)
We're supported by [GitHub Actions](https://github.com/features/actions)

<a href="https://travis-ci.org/"><img src="https://travis-ci.com/images/logos/TravisCI-Full-Color.png" width="144px"></a>
<a href="https://github.com/features/actions"><img src="https://github.githubassets.com/images/modules/site/features/actions-icon-actions.svg" width="144px"></a>

### BrowserStack

Expand Down
Loading

0 comments on commit 1191c3f

Please sign in to comment.