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: switch from travis-ci to github actions #214

Merged
merged 26 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c57e6ee
build: switch from travis-ci to github actions
Nov 5, 2019
c74c11a
build: switch from travis-ci to github actions
Nov 5, 2019
6b1ab3e
build: switch from travis-ci to github actions
Nov 5, 2019
28e144c
build: switch from travis-ci to github actions
Nov 5, 2019
70cc501
build: switch from travis-ci to github actions
Nov 5, 2019
7088e58
build: switch from travis-ci to github actions
Nov 5, 2019
529ad1d
build: switch from travis-ci to github actions
Nov 5, 2019
9dc335c
build: switch from travis-ci to github actions
Nov 5, 2019
35f473b
build: switch from travis-ci to github actions
Nov 5, 2019
1a152c6
build: switch from travis-ci to github actions
Nov 6, 2019
8551c83
build: switch from travis-ci to github actions
Nov 6, 2019
5c39491
build: switch from travis-ci to github actions
Nov 6, 2019
3f51243
build: switch from travis-ci to github actions
Nov 6, 2019
5fd54e3
build: switch from travis-ci to github actions
Nov 6, 2019
cd6c3b3
build: switch from travis-ci to github actions
Nov 6, 2019
5f26129
build: switch from travis-ci to github actions
Nov 6, 2019
58fbd4c
build: switch from travis-ci to github actions
Nov 6, 2019
6bcd1af
build: switch from travis-ci to github actions
Nov 6, 2019
959da3a
build: switch from travis-ci to github actions
Nov 6, 2019
2a4fe66
build: switch from travis-ci to github actions
Nov 7, 2019
ebd8b6a
build: switch from travis-ci to github actions
Nov 7, 2019
7992161
build: switch from travis-ci to github actions
Nov 7, 2019
190fc78
build: switch from travis-ci to github actions
Nov 7, 2019
e969352
build: switch from travis-ci to github actions
Nov 7, 2019
e8d6aa1
build: switch from travis-ci to github actions
Nov 7, 2019
e6a8f15
build: switch from travis-ci to github actions
Nov 7, 2019
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
336 changes: 336 additions & 0 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
name: Continuous Integration
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max_old_space_size=6144
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
id: node_modules_cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.node_modules_cache.outputs.cache-hit != 'true'
run: npm ci

- name: Migrate public to business components
run: npm run build:angular-business:public2business

- name: Restore @sbb-esta/angular-core from cache
uses: actions/cache@v1
id: sbb_esta_angular_core_cache
with:
path: dist/sbb-esta/angular-core
key: "ng-sbb-esta-angular-core-\
${{ hashFiles('**/projects/sbb-esta/angular-core/**/*.ts') }}-\
${{ hashFiles('**/projects/sbb-esta/angular-core/**/*.scss') }}"
- name: Build @sbb-esta/angular-core
if: steps.sbb_esta_angular_core_cache.outputs.cache-hit != 'true'
run: npm run build:angular-core

- name: Restore @sbb-esta/angular-icons from cache
uses: actions/cache@v1
id: sbb_esta_angular_icons_cache
with:
path: dist/sbb-esta/angular-icons
key: "ng-sbb-esta-angular-icons-\
${{ hashFiles('**/projects/sbb-esta/angular-icons/**/*.ts') }}"
- name: Build @sbb-esta/angular-icons
if: steps.sbb_esta_angular_icons_cache.outputs.cache-hit != 'true'
run: npm run build:angular-icons

- name: Restore @sbb-esta/angular-keycloak from cache
uses: actions/cache@v1
id: sbb_esta_angular_keycloak_cache
with:
path: dist/sbb-esta/angular-keycloak
key: "ng-sbb-esta-angular-keycloak-\
${{ hashFiles('**/projects/sbb-esta/angular-keycloak/**/*.ts') }}"
- name: Build @sbb-esta/angular-keycloak
if: steps.sbb_esta_angular_keycloak_cache.outputs.cache-hit != 'true'
run: npm run build:angular-keycloak

- name: Restore @sbb-esta/angular-public from cache
uses: actions/cache@v1
id: sbb_esta_angular_public_cache
with:
path: dist/sbb-esta/angular-public
key: "ng-sbb-esta-angular-public-\
${{ hashFiles('**/projects/sbb-esta/angular-public/**/*.ts') }}-\
${{ hashFiles('**/projects/sbb-esta/angular-public/**/*.html') }}-\
${{ hashFiles('**/projects/sbb-esta/angular-public/**/*.scss') }}"
- name: Build @sbb-esta/angular-public
if: steps.sbb_esta_angular_public_cache.outputs.cache-hit != 'true'
run: npm run build:angular-public

- name: Restore @sbb-esta/angular-business from cache
uses: actions/cache@v1
id: sbb_esta_angular_business_cache
with:
path: dist/sbb-esta/angular-business
key: "ng-sbb-esta-angular-business-\
${{ hashFiles('**/projects/sbb-esta/angular-business/**/*.ts') }}-\
${{ hashFiles('**/projects/sbb-esta/angular-business/**/*.html') }}-\
${{ hashFiles('**/projects/sbb-esta/angular-business/**/*.scss') }}"
- name: Build @sbb-esta/angular-business
if: steps.sbb_esta_angular_business_cache.outputs.cache-hit != 'true'
run: npm run build:angular-business

- name: Store build artifacts
uses: actions/upload-artifact@v1
with:
name: dist-sbb-esta
path: dist/sbb-esta

lint:
runs-on: ubuntu-latest
needs: build
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
id: node_modules_cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.node_modules_cache.outputs.cache-hit != 'true'
run: npm ci

- name: Create lint output directory
run: mkdir lint
- name: Linting @sbb-esta/angular-core
run: npx ng lint @sbb-esta/angular-core --format=json > lint/core.json
- name: Linting @sbb-esta/angular-icons
run: npx ng lint @sbb-esta/angular-icons --format=json > lint/icons.json
- name: Linting @sbb-esta/angular-keycloak
run: npx ng lint @sbb-esta/angular-keycloak --format=json > lint/keycloak.json
- name: Linting @sbb-esta/angular-public
run: npx ng lint @sbb-esta/angular-public --format=json > lint/public.json
- name: Linting @sbb-esta/angular-business
run: npx ng lint @sbb-esta/angular-business --format=json > lint/business.json
- name: Linting @sbb-esta/angular-showcase
run: npx ng lint angular-showcase --format=json > lint/showcase.json

- name: Save lint results
uses: actions/upload-artifact@v1
with:
name: lint-report
path: lint

test:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
env:
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
id: node_modules_cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.node_modules_cache.outputs.cache-hit != 'true'
run: npm ci

- name: Restore build artifacts
uses: actions/download-artifact@v1
with:
name: dist-sbb-esta
path: dist/sbb-esta

- name: Testing @sbb-esta/angular-core
run: npx ng test @sbb-esta/angular-core -c ci
- name: Testing @sbb-esta/angular-keycloak
run: npx ng test @sbb-esta/angular-keycloak -c ci
- name: Testing @sbb-esta/angular-public
run: npx ng test @sbb-esta/angular-public -c ci
- name: Testing @sbb-esta/angular-business
run: npx ng test @sbb-esta/angular-business -c ci

- name: Save test results
uses: actions/upload-artifact@v1
with:
name: coverage-report
path: coverage

test-pr:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'pull_request'
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
id: node_modules_cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.node_modules_cache.outputs.cache-hit != 'true'
run: npm ci

- name: Restore build artifacts
uses: actions/download-artifact@v1
with:
name: dist-sbb-esta
path: dist/sbb-esta

- name: Testing @sbb-esta/angular-core PR
run: npx ng test @sbb-esta/angular-core -c pr
- name: Testing @sbb-esta/angular-keycloak PR
run: npx ng test @sbb-esta/angular-keycloak -c pr
- name: Testing @sbb-esta/angular-public PR
run: npx ng test @sbb-esta/angular-public -c pr
- name: Testing @sbb-esta/angular-business PR
run: npx ng test @sbb-esta/angular-business -c pr

- name: Save test results
uses: actions/upload-artifact@v1
with:
name: coverage-report
path: coverage

sonar:
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push'
steps:
- name: Full checkout
uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
id: node_modules_cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.node_modules_cache.outputs.cache-hit != 'true'
run: npm ci

- name: Prepare sonar configuration
run: node scripts/sonar.js
- name: Restore lint artifacts
uses: actions/download-artifact@v1
with:
name: lint-report
path: lint
- name: Restore test artifacts
uses: actions/download-artifact@v1
with:
name: coverage-report
path: coverage
- name: Adapt lcov paths
run: find ./coverage -name lcov.info -type f -exec sed -i -e "s|SF:$GITHUB_WORKSPACE|SF:/github/workspace|g" {} \;
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@v1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

showcase:
runs-on: ubuntu-latest
needs: build
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
id: node_modules_cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.node_modules_cache.outputs.cache-hit != 'true'
run: npm ci

- name: Restore build artifacts
uses: actions/download-artifact@v1
with:
name: dist-sbb-esta
path: dist/sbb-esta

- name: Build showcase
run: npm run build:angular-showcase
- name: Copy showcase package.json
run: cp projects/angular-showcase/package.json dist/angular-showcase

- name: Save showcase artifact
uses: actions/upload-artifact@v1
with:
name: showcase
path: dist/angular-showcase

deploy-staging:
runs-on: ubuntu-latest
needs: showcase
if: github.event_name == 'pull_request'
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Restore showcase artifact
uses: actions/download-artifact@v1
with:
name: showcase
path: dist/angular-showcase
- name: Assign showcase version
run: sed -i "s/0.0.0-PLACEHOLDER/0.0.0-$PR_NUMBER/g" dist/angular-showcase/package.json
- name: Pack showcase
run: |
cd dist/angular-showcase
npm pack
- name: Deploy to staging
run: |
curl --url https://angular-staging.app.sbb.ch/$PR_NUMBER \
-X POST --user sbb:ezUxDHgb6rAHTDU0HLHJ \
-F "tarball=@dist/angular-showcase/sbb-esta-angular-showcase-0.0.0-$PR_NUMBER.tgz"
Loading