Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
62d569b
feat: TT-509 Use terraform to provision ui infraestructure
jatobrun Mar 8, 2022
3fe4e5e
fix: TT-509 expose port 8080 in docker images
jatobrun Mar 10, 2022
6cc64e6
fix: TT-509 change app to port 80
jatobrun Mar 14, 2022
483cf6a
fix: TT-509 including empty line in all files
jatobrun Mar 15, 2022
a4b8426
fix: TT-509 Change the dockerfile to use root user and not app user
jatobrun Mar 16, 2022
da8e769
parent bf8977e79ef18ac85a09f9c55b213c72146c0de7
heikergil Mar 10, 2022
06735a0
fix: TT-513 tests cd-stage.yml
heikergil Mar 16, 2022
09235cf
feat: TT-513 CD - Prod yaml file
santii90ec Mar 16, 2022
d85bbe2
fix: TT-513 tests azure credentials
heikergil Mar 17, 2022
9cce0c9
fix: TT-513 change image tag variable
heikergil Mar 17, 2022
8b6fd37
fix: TT-513 add acr
heikergil Mar 17, 2022
81dae65
fix: TT-513 fix make publish
heikergil Mar 17, 2022
16671fe
fix: TT-513 fix make
heikergil Mar 17, 2022
0e496cc
fix: TT-513 change acr
heikergil Mar 17, 2022
cb9246a
feat: TT-513 cli test and dev test make file
santii90ec Mar 17, 2022
aebce8d
Merge branch 'TT-513-Create-CI/CD-pipeline-in-timer-tracker-ui-to-dep…
santii90ec Mar 17, 2022
b434d10
Merge branch 'TT-513-Create-CI/CD-pipeline-in-timer-tracker-ui-to-dep…
heikergil Mar 17, 2022
dd8f99d
TT-513 fix make publish command
heikergil Mar 17, 2022
fcd887c
fix: TT-513 change registry url
heikergil Mar 17, 2022
4a60730
fix: TT-513 fix registry url
heikergil Mar 17, 2022
15af506
fix: TT-513 test CI/CD pipeline
heikergil Mar 21, 2022
e5a3dd1
fix: TT-513 tests cd/ci make build
heikergil Mar 21, 2022
ab6e6fe
fix: TT-513 test tf init on ci/cd
heikergil Mar 21, 2022
2c6c80f
fix: TT-513 Fix CI on all PR
santii90ec Mar 21, 2022
275642d
fix: TT-513 Fix CI pipeline
santii90ec Mar 21, 2022
779e907
fix: TT-513 Fix Make file for dev testing
santii90ec Mar 22, 2022
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
Prev Previous commit
Next Next commit
parent bf8977e
author Heiker Gil <[email protected]> 1646927329 -0500
committer Santiago Atapuma <[email protected]> 1647463991 -0500

parent bf8977e
author Heiker Gil <[email protected]> 1646927329 -0500
committer Santiago Atapuma <[email protected]> 1647463401 -0500

fix: TT-513 CI/CD fix files

feat: TT-513 cd-stage workflows

feat: TT-513 fix indent cd-stage.yml

feat: TT-513 fix indent cd-stage.yml

fix: TT-513 fix indent cd-stage.yml

feat: TT-513 add ci.yml

feat: TT-513 add ci.yml

fix: TT-513 fix ci.yml

fix: TT-513 ci.yml

feat: TT-513 add cd-prod.yml

Update time-tracker-ui-ci.yml

fix: TT-513 ci.yml

Update time-tracker-ui-ci.yml

feat: TT-513 environment variables

fix: TT-513 .env variables

fix: TT-513 env variables

fix: TT-513 fix make file

fix: TT-513 install chrome with dockerfile

fix: TT-513 install chrome on docker container

fix: TT-513 fix docker file

fix: karma.conf.js to run headless

fix: TT-513 change tests to ci-test scrip

fix: TT-513 fix docker file

fix: TT-513 karma testing

fix: TT-513 add chrome to docker img

fix: TT-513 change chrome download url

fix: TT-513 fix chorme install

fix: TT-513 change make to ci-test

fix: TT-513 fix coverage

fix: TT-513 fix permissions

fix: TT-513 Fix Permissions in home

fix: TT-513 fix permissions

fix: TT-513 fix permissions

fix: TT-573 fix permission}

fix: TT-513 fix permissions

fix: TT-573 fix permissions

fix: TT-513 Fix permissions

fix: TT-513 fix permissions

fix: TT-513 Fix Permissions

fix: TT-513 Fix Permissions

fix: TT-513 Permissions

fix: TT-513 disable karma coverage test

fix: TT-513 Fix CLI
  • Loading branch information
heikergil authored and santii90ec committed Mar 16, 2022
commit da8e769c28d8345a3de945edf7105eb167c7974d
52 changes: 52 additions & 0 deletions .github/workflows/time-tracker-cd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: time-tracker-ui-cd-prod

on:
release:
types:
- published

jobs:
cd:
runs-on: ubuntu-latest
env:
TF_WORKSPACE: prod
WORKING_DIR: infrastructure/
ARM_CLIENT_ID: ${{secrets.TF_ARM_CLIENT_ID}}
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
ARM_TENANT_ID: ${{secrets.TF_ARM_TENANT_ID}}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get the release_version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: Login to azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Build the docker image
run: make build

- name: Publish docker image to prod azure container registry
run: |
make login publish acr=timetrackerserviceprodregistry image_tag=$RELEASE_VERSION
- name: Setup terraform
uses: hashicorp/setup-terraform@v1

- name: Authenticate with the TF modules repository
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}

- name: Terraform Init
working-directory: ${{ env.WORKING_DIR }}
run: terraform init

- name: Terraform Apply
working-directory: ${{ env.WORKING_DIR }}
run: terraform apply -lock=false -var-file="${{ env.TF_WORKSPACE }}.tfvars" -var "image_tag=$RELEASE_VERSION" -auto-approve
45 changes: 45 additions & 0 deletions .github/workflows/time-tracker-ui-cd-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: time-tracker-ui-cd-stage

on:
push:
tags:
- 'v*.*.*'

jobs:
cd:
runs-on: ubuntu-latest
env:
TF_WORKSPACE: stage
WORKING_DIR: infrastructure/
ARM_CLIENT_ID: ${{secrets.TF_ARM_CLIENT_ID}}
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
ARM_TENANT_ID: ${{secrets.TF_ARM_TENANT_ID}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get the release_version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: Login to azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build the docker image
run: make build
- name: Publish docker image to stage azure container registry
run: |
make login publish acr=timetrackerservicestageregistry image_tag=$RELEASE_VERSION
- name: Setup terraform
uses: hashicorp/setup-terraform@v1
- name: Authenticate with the TF modules repository
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}
- name: Terraform Init
working-directory: ${{ env.WORKING_DIR }}
run: terraform init
- name: Terraform Apply
working-directory: ${{ env.WORKING_DIR }}
run: terraform apply -lock=false -var-file="${{ env.TF_WORKSPACE }}.tfvars" -var "image_tag=$RELEASE_VERSION" -auto-approve
150 changes: 150 additions & 0 deletions .github/workflows/time-tracker-ui-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: time-tracker-ui-ci

on:
push:
branches:
- TT-513-Create-CI/CD-pipeline-in-timer-tracker-ui-to-deploy-changes-for-both-environments

pull_request:
branches:
- master

jobs:
ci:
runs-on: ubuntu-latest
env:
WORKING_DIR: infrastructure/
DB_CONNECTION: ${{ secrets.DB_CONNECTION }}
ARM_CLIENT_ID: ${{secrets.TF_ARM_CLIENT_ID}}
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
ARM_TENANT_ID: ${{secrets.TF_ARM_TENANT_ID}}
strategy:
max-parallel: 5
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Authenticate with the TF modules repository
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}

# ci-test:
# name: Unit tests and CodeCoverage
# timeout-minutes: 90
# steps:
# - name: Set up Node.js version
# uses: actions/setup-node@v1
# with:
# node-version: '12.x'

# - name: Install dependencies
# run: npm install

- name: build docker
run: make build

- name: Inject Secrets
env:
SCOPES: ${{ secrets.SCOPES }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
AUTHORITY: ${{ secrets.AUTHORITY }}
STACK_EXCHANGE_ID: ${{ secrets.STACK_EXCHANGE_ID }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
run: |
chmod +x ./scripts/populate-keys.sh
sh ./scripts/populate-keys.sh

- name: Running tests
run: |
chmod -R 777 ./$home
make test
- name: Generate coverage report
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)

- name: Setup terraform
uses: hashicorp/setup-terraform@v1

- name: 'Terraform Init'
id: init
working-directory: ./${{ env.WORKING_DIR }}
run: terraform init

- name: 'Terraform validate'
id: validate
working-directory: ./${{ env.WORKING_DIR }}
run: terraform validate

- name: Terraform Plan Stage
id: plan-stage
if: github.event_name == 'pull_request'
run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -no-color
continue-on-error: true
working-directory: ./${{ env.WORKING_DIR }}
env:
TF_WORKSPACE: stage

- name: Terraform Plan Prod
id: plan-prod
if: github.event_name == 'pull_request'
run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -no-color
continue-on-error: true
working-directory: ./${{ env.WORKING_DIR }}
env:
TF_WORKSPACE: prod

- name: Update Pull Request with Stage Plan
uses: actions/[email protected]
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan-stage.outputs.stdout }}"
TF_WORKSPACE: stage
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### [${{ env.WORKING_DIR }}][${{ env.TF_WORKSPACE }}] Terraform Plan 📖 \`${{ steps.plan-stage.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Update Pull Request with Prod Plan
uses: actions/[email protected]
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan-prod.outputs.stdout }}"
TF_WORKSPACE: prod
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### [${{ env.WORKING_DIR }}][${{ env.TF_WORKSPACE }}] Terraform Plan 📖 \`${{ steps.plan-prod.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Terraform Plan Stage Status
if: steps.plan-stage.outcome == 'failure'
run: exit 1

- name: Terraform Plan Prod Status
if: steps.plan-prod.outcome == 'failure'
run: exit 1
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,43 @@ FROM node:14 AS development

ENV USERNAME timetracker
ENV HOME /home/${USERNAME}
ENV CHROME_BIN /opt/google/chrome/google-chrome
#Essential tools and xvfb
RUN apt-get update && apt-get install -y \
software-properties-common \
unzip \
curl \
wget \
xvfb

#Chrome browser to run the tests
ARG CHROME_VERSION=65.0.3325.181
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add \
&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& dpkg -i google-chrome-stable_current_amd64.deb || true
RUN apt-get install -y -f \
&& rm -rf /var/lib/apt/lists/*

#Disable the SUID sandbox so that chrome can launch without being in a privileged container
RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
&& echo "#! /bin/bash\nexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome \
&& chmod 755 /opt/google/chrome/google-chrome

#Chrome Driver
ARG CHROME_DRIVER_VERSION=2.37
RUN mkdir -p /opt/selenium \
&& curl http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -o /opt/selenium/chromedriver_linux64.zip \
&& cd /opt/selenium; unzip /opt/selenium/chromedriver_linux64.zip; rm -rf chromedriver_linux64.zip; ln -fs /opt/selenium/chromedriver /usr/local/bin/chromedriver;

RUN useradd -ms /bin/bash ${USERNAME}

WORKDIR ${HOME}/time-tracker-ui
COPY . .
RUN rm -f .env
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
RUN chmod -R 777 ${HOME}/time-tracker-ui



USER ${USERNAME}
RUN npm cache clean --force && npm install
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ remove: ## Delete container timetracker_ui.
.PHONY: test
test: ## Run all tests on docker container timetracker_ui.
docker-compose --env-file ./.env up -d
docker exec -it timetracker_ui bash -c "npm run test"
docker exec -i timetracker_ui bash -c "npm run ci-test"

.PHONY: publish
publish: ## Publish the container image timetracker_ui.
Expand Down
19 changes: 10 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- 4200:4200
- 9876:9876
environment:
CHROME_BIN: /opt/google/chrome/google-chrome
AUTHORITY: ${AUTHORITY}
CLIENT_ID: ${CLIENT_ID}
SCOPES: ${SCOPES}
Expand All @@ -20,12 +21,12 @@ services:
AUTHORITY_JSON: ${AUTHORITY_JSON}
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
SCOPES_JSON: ${SCOPES_JSON}
volumes:
- ./src:/home/timetracker/time-tracker-ui/src/
- ./scripts:/home/timetracker/time-tracker-ui/scripts/
- ./e2e:/home/timetracker/time-tracker-ui/e2e/
- ./coverage:/home/timetracker/time-tracker-ui/coverage
- ./angular.json:/home/timetracker/time-tracker-ui/angular.json
- ./karma.conf.js:/home/timetracker/time-tracker-ui/karma.conf.js
- ./package.json:/home/timetracker/time-tracker-ui/package.json
- ./webpack.config.js:/home/timetracker/time-tracker-ui/webpack.config.js
# volumes:
# # - ./src:/home/timetracker/time-tracker-ui/src/
# # - ./scripts:/home/timetracker/time-tracker-ui/scripts/
# # - ./e2e:/home/timetracker/time-tracker-ui/e2e/
# # - ./coverage:/home/timetracker/time-tracker-ui/coverage
# # - ./angular.json:/home/timetracker/time-tracker-ui/angular.json
# # - ./karma.conf.js:/home/timetracker/time-tracker-ui/karma.conf.js
# # - ./package.json:/home/timetracker/time-tracker-ui/package.json
# # - ./webpack.config.js:/home/timetracker/time-tracker-ui/webpack.config.js
11 changes: 9 additions & 2 deletions e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ exports.config = {
'./src/**/*.e2e-spec.ts'
],
capabilities: {
browserName: 'chrome'
browserName: 'chrome',
'chromeOptions': {
'args': [
'--no-sandbox',
'--headless',
'--window-size=1024,768'
]
}
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
Expand All @@ -29,4 +36,4 @@ exports.config = {
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
};
7 changes: 7 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html


module.exports = function (config) {
config.set({
basePath: '',
Expand All @@ -21,6 +22,12 @@ module.exports = function (config) {
seed: '90967',
}, // leave Jasmine Spec Runner output visible in browser
},
// Karma Typescript compiler options
karmaTypescriptConfig: {
coverageOptions : {
instrumentation: false
}
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/time-tracker'),
reports: ['html', 'lcovonly', 'text-summary'],
Expand Down
16 changes: 8 additions & 8 deletions scripts/populate-keys.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

> src/environments/keys.ts
echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts
echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts
echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts
echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts
echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts
echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts
cat src/environments/keys.ts
> .env
echo 'AUTHORITY = '$AUTHORITY'' >> .env
echo 'CLIENT_ID = '$CLIENT_ID'' >> .env
echo 'SCOPES = '$SCOPES'' >> .env
echo 'STACK_EXCHANGE_ID = '$STACK_EXCHANGE_ID'' >> .env
echo 'STACK_EXCHANGE_ACCESS_TOKEN = '$STACK_EXCHANGE_ACCESS_TOKEN'' >> .env
echo 'AZURE_APP_CONFIGURATION_CONNECTION_STRING = '$AZURE_APP_CONFIGURATION_CONNECTION_STRING'' >> .env
cat .env