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

12382 - Add in CI for frontend. #283

Merged
merged 17 commits into from
May 30, 2022
Merged
88 changes: 88 additions & 0 deletions .github/workflows/vue-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: SBC-Common-Components Web CI

on:
pull_request:
branches:
- master
seeker25 marked this conversation as resolved.
Show resolved Hide resolved
paths:
- "vue/sbc-common-components/**"

defaults:
run:
shell: bash
working-directory: ./vue/sbc-common-components

jobs:
setup-job:
runs-on: ubuntu-20.04

if: github.repository == 'bcgov/sbc-common-components'

steps:
- uses: actions/checkout@v2
- run: "true"

linting:
needs: setup-job
runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
make setup
- name: Linting
run: |
make lint

testing-coverage:
needs: setup-job
runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
make setup
- name: Test with Jest
id: test
run: |
make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
flags: sbccommoncomponentsweb
name: codecov-vue
fail_ci_if_error: true

build-check:
needs: setup-job
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
make setup
- run: npm run build --if-present
working-directory: ./vue/sbc-common-components/
39 changes: 39 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
codecov:
require_ci_to_pass: true
branch: master
max_report_age: false

coverage:
precision: 2
round: down
range: "5...100"
status:
patch: false
project:
default: false
ui:
target: 5%
flags:
- sbccommoncomponentsweb

ignore:
- "^/tests/**/*" # ignore test harness code

parsers:
gcov:
branch_detection:
conditional: true
loop: true
method: false
macro: false

comment:
layout: "diff,flags,tree"
behavior: default
require_changes: true

flags:
sbccommoncomponentsweb:
paths:
- vue/sbc-common-components/src
carryforward: true
2 changes: 2 additions & 0 deletions vue/sbc-common-components/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
**/dist
48 changes: 48 additions & 0 deletions vue/sbc-common-components/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.PHONY: setup
.PHONY: ci cd

PROJECT_NAME:=sbc-common-components-web
DOCKER_NAME:=sbc-common-components-web

#################################################################################
# COMMANDS -- Setup
# expects the terminal to be openshift login
# expects export OPENSHIFT_REPOSITORY=""
#################################################################################
setup: ## Clean and Install npm dependencies
npm ci

create-env: ## create the configration files from dev
@oc get configmap $(DOCKER_NAME)-dev-keycloak-config -n "$(OPENSHIFT_REPOSITORY)-dev" \
-o json | jq -r '.data["keycloak.json"]' > ./public/config/kc/keycloak.json.dev
@oc get configmap $(DOCKER_NAME)-dev-ui-configuration -n "$(OPENSHIFT_REPOSITORY)-dev" \
-o json | jq -r '.data["configuration.json"]' > ./public/config/configuration.json.dev

#################################################################################
# COMMANDS - CI #
#################################################################################
ci: lint test

lint: ## Run linting ofcode.
npm run lint

test: ## Unit testing
npm run test:unit

build: ## Build the docker container
docker build . -t $(DOCKER_NAME) \
--build-arg VCS_REF=$(shell git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \

build-nc: ## Build the docker container without caching
docker build --no-cache -t $(DOCKER_NAME) .

#################################################################################
# Self Documenting Commands #
#################################################################################
.PHONY: help

.DEFAULT_GOAL := help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Loading