Skip to content

Commit e99e797

Browse files
committed
Migrate from Travis CI to GitHub Actions
1 parent 0a8fb95 commit e99e797

4 files changed

Lines changed: 106 additions & 5 deletions

File tree

.github/workflows/nodejs.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Build
2+
3+
on: [push]
4+
5+
jobs:
6+
7+
# -- TESTS ------------------------------------------------------------------
8+
tests:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
node-version: [12.x]
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
24+
- name: Install dependencies
25+
run: npm install
26+
27+
- name: Run Unit-Tests + Code Coverage
28+
run: npm run test:coverage
29+
30+
- name: Save Code Coverage
31+
uses: actions/upload-artifact@v2
32+
with:
33+
name: code-coverage
34+
path: coverage
35+
36+
sonarcloud:
37+
runs-on: ubuntu-latest
38+
needs: tests
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v2
43+
44+
- name: Download Code Coverage
45+
uses: actions/download-artifact@v2
46+
with:
47+
name: code-coverage
48+
path: coverage
49+
50+
- name: Get App Version
51+
run: ./scripts/version.sh
52+
53+
- name: SonarCloud Scan
54+
uses: sonarsource/sonarcloud-github-action@master
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
58+
59+
# functional-tests:
60+
# runs-on: ubuntu-latest
61+
# needs: tests
62+
63+
# steps:
64+
# - name: Checkout
65+
# uses: actions/checkout@v2
66+
67+
# - name: Build docker image
68+
# run: docker build -t timoa/nodejs-encryption-api-example .
69+
70+
# - name: Start Docker container
71+
# run: docker-compose up -d
72+
73+
# - name: Check Docker container status
74+
# run: docker ps -a
75+
76+
# - name: Install dependencies
77+
# run: npm install
78+
79+
# - name: Run Functional tests
80+
# run: npm run test:functional
81+
82+
# - name: Stop Docker container
83+
# run: docker-compose down
84+
85+
# -- BUILD ------------------------------------------------------------------
86+
build:
87+
runs-on: ubuntu-latest
88+
needs: tests
89+
if: github.ref == 'refs/heads/master'
90+
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@v2
94+
95+
- name: Docker Build
96+
uses: docker/build-push-action@v1
97+
with:
98+
username: ${{ secrets.DOCKER_USERNAME }}
99+
password: ${{ secrets.DOCKER_PASSWORD }}
100+
repository: timoa/nodejs-encryption-api-example
101+
tags: latest
102+

scripts/docker_push.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ function readJson {
2020

2121
VERSION=`readJson package.json version` || exit 1;
2222

23-
sonar-scanner -X -Dsonar.projectVersion=$VERSION
23+
echo $VERSION

sonar-project.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ sonar.links.issue=https://github.com/timoa/nodejs-encryption-api-example/issues
1717

1818
sonar.host.url=https://sonarcloud.io
1919
sonar.organization=timoa-github
20-
sonar.login=timoa@github
20+
sonar.scm.provider=git
21+
sonar.pullrequest.provider=github
22+
sonar.pullrequest.github.repository=timoa/nodejs-encryption-api-example
2123
sonar.sources=src
2224
sonar.exclusions=node_modules/**/*
2325

0 commit comments

Comments
 (0)