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

Pull request to test PR workflow #40

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
111 changes: 21 additions & 90 deletions .github/workflows/chapter4-e2e-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,106 +32,37 @@ jobs:
path: ./target/digibank*

analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
name: Analyze Code
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: .github/codeql/codeql-config.yml # Optional: Add a custom config file if available

- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Build Code for Analysis
run: |
if [ "${{ matrix.language }}" == "java" ]; then
mvn clean install -DskipTests;
fi
shell: bash

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

cleanup:
needs: [build]
runs-on: ubuntu-latest
environment: UAT

steps:
- name: "cleanup destination at ${{ vars.UAT_IP }}"
uses: appleboy/ssh-action@master
with:
host: ${{ vars.UAT_IP }}
port: ${{ vars.UAT_PORT }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
script: |
rm -rf ./deployment/*
rm -rf ${{ vars.UAT_TOMCAT }}/digi*

deploy:
needs: [cleanup]
runs-on: ubuntu-latest
environment: UAT

steps:
- uses: actions/download-artifact@v2
with:
name: digibank.war
path: ./deploy

- run: ls -ltr ./deploy

- name: deploy
uses: appleboy/scp-action@master
with:
host: ${{ vars.UAT_IP }}
port: ${{ vars.UAT_PORT }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
source: './deploy/digibank.war'
target: 'deployment'

install:
needs: [deploy]
runs-on: ubuntu-latest
environment: UAT

steps:
- name: "cleanup destination at ${{ vars.UAT_IP }}"
uses: appleboy/ssh-action@master
with:
host: ${{ vars.UAT_IP }}
port: ${{ vars.UAT_PORT }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
script: cp -f /home/ec2-user/deployment/deploy/digibank.war ${{ vars.UAT_TOMCAT }}

- name: Sleep for 10 seconds
run: sleep 10s
shell: bash

e2e-tests:
needs: [install]
runs-on: ubuntu-latest
environment: UAT
name: Trigger E2E Tests on UAT Environment

steps:
- name: Trigger Workflow from e2e tests with Playwright
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/tau-github-actions-for-testing/tau-digital-bank-e2e-tests/dispatches \
-d '{"event_type": "trigger-tests", "client_payload" : { "sut" : "${{ vars.UAT_IP }}" } }'
category: "/language:${{ matrix.language }}"
52 changes: 52 additions & 0 deletions .github/workflows/end2end-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: e2e pipeline
run-name: Build, Deploy, Test - from user @${{ github.actor }}

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven

- name: Run Unit Tests
run: mvn test

analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
25 changes: 25 additions & 0 deletions .github/workflows/new-nightly-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: nightly build at 1pm

on:
push:
schedule:
- cron: '0 13 * * *'

jobs:
nightly_build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2

- name: Run unit test
run: mvn test

- name: Build with Maven
run: mvn -DskipTests -B package --no-transfer-progress --file ./pom.xml

- name: Upload WAR artifact
uses: actions/upload-artifact@v3
with:
name: digibank.war
path: ./target/*digitalbank*.war
20 changes: 20 additions & 0 deletions .github/workflows/new-run-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This is a basic workflow that is manually triggered
name: run unit test of feature branches

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
push:
branches:
'feature/*'
jobs:
run-unit-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4.2.2

- name: run unit test
run: mvn test

25 changes: 25 additions & 0 deletions .github/workflows/new2-nightly-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: nightly build at 1pm

on:
push:
schedule:
- cron:

jobs:
nightly_build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2

- name: Run unit test
run: mvn test

- name: Build with Maven
run: mvn -DskipTests -B package --no-transfer-progress --file ./pom.xml

- name: Upload WAR artifact
uses: actions/upload-artifact@v3
with:
name: digibank.war
path: ./target/*digitalbank*.war
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![nightly build at 11pm](https://github.com/tau-github-actions-for-testing/tau-digital-bank/actions/workflows/nightly-build.yml/badge.svg)](https://github.com/tau-github-actions-for-testing/tau-digital-bank/actions/workflows/nightly-build.yml)
[![nightly build at 1pm](https://github.com/tareqmamun14/tau-digital-bank/actions/workflows/new-nightly-build.yml/badge.svg)](https://github.com/tareqmamun14/tau-digital-bank/actions/workflows/new-nightly-build.yml)

# Digital Bank

Expand Down