Skip to content

Commit

Permalink
12382 - Add in CI for frontend. (#283)
Browse files Browse the repository at this point in the history
* Add in CI for frontend.

* Change branch back to master.

* Add in install dependencies.

* Fix makefile.

* Add in Dockerfile.

* Missing nginx.conf.

* Remove hello1, hello2.

* Minor unit test fixes.

* Update package-lock.json

* Delete Dockerfile and nginx.conf.

* Minor CI changes.

* Spacing issue.

* Path fix.

* Add in codecov.yaml.

* Fix path.

* Update package.json with coverage flag.

* Fix branch to master.
  • Loading branch information
seeker25 authored May 30, 2022
1 parent 3777631 commit d7121fc
Show file tree
Hide file tree
Showing 10 changed files with 361 additions and 195 deletions.
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
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

0 comments on commit d7121fc

Please sign in to comment.