Skip to content

Continuous Integration #1114

Continuous Integration

Continuous Integration #1114

# Copyright 2020 SkillTree
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Continuous Integration
on:
push:
paths-ignore:
- 'README.md'
- '.gitlab-ci.yml'
pull_request:
paths-ignore:
- 'README.md'
- '.gitlab-ci.yml'
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: skillsPassword
POSTGRES_DB: skills
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.17.0'
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '19' # The JDK version to make available on the path.
- name: Print Versions
run: |
mvn --version
java -version
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: get latest skill-service release
run: |
curl -s https://api.github.com/repos/NationalSecurityAgency/skills-service/releases/latest | grep browser_download_url | cut -d '"' -f 4 | wget -qi -
ls ./
- name: Build java-backend-example service
run: |
cd java-backend-example
mvn --batch-mode install
cd ..
- name: Install js-example
run: |
cd js-example
npm install
cd ..
- name: Run Cypress Tests
run: |
cd e2e-tests
npm install
npm run services:start:skills-service
npm run services:start:java-backend-example
npm run services:start:js
npm run cy:run
- name: upload result artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: result artifacts - with jar
path: |
./e2e-tests/cypress
./e2e-tests/logs
./e2e-tests/target/logs
./js-example/target/logs
build-and-test-with-docker-service:
runs-on: ubuntu-latest
services:
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: skillsPassword
POSTGRES_DB: skills
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.17.0'
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '19' # The JDK version to make available on the path.
- name: Print Versions
run: |
mvn --version
java -version
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: run skill-service
run: |
LATEST_TAG=$(wget -q https://registry.hub.docker.com/v2/repositories/skilltree/skills-service/tags -O - | jq -r ".results[].name" | sort | tail -n1)
docker run --name skills-service --network host -d -p 8080:8080 -e SPRING_PROPS="spring.datasource.url=jdbc:postgresql://localhost:5432/skills,spring.datasource.username=postgres,spring.datasource.password=skillsPassword" skilltree/skills-service:${LATEST_TAG}
- name: Build java-backend-example service
run: |
cd java-backend-example
mvn --batch-mode install
cd ..
- name: Install js-example
run: |
cd js-example
npm install
cd ..
- name: Run Cypress Tests
run: |
cd e2e-tests
npm install
npm run services:start:java-backend-example
npm run services:start:js
npm run cy:run
- name: Save docker logs
if: ${{ always() }}
run: |
mkdir ./e2e-tests/logs
docker logs skills-service > ./e2e-tests/logs/skills-service-logs.txt
- name: upload result artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: result artifacts - with docker
path: |
./e2e-tests/cypress
./e2e-tests/logs
./e2e-tests/target/logs
./js-example/target/logs