Skip to content

Commit e532601

Browse files
Merge branch 'main' into hotfix
2 parents 2968a56 + fcf538e commit e532601

File tree

5 files changed

+270
-0
lines changed

5 files changed

+270
-0
lines changed

.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E501
4+
exclude = .venv, frontend
5+
ignore = E203, W503, G004, G200

.github/workflows/codeql.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "main", "dev", "demo" ]
17+
pull_request:
18+
branches: [ "main", "dev", "demo" ]
19+
schedule:
20+
- cron: '44 20 * * 2'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- language: javascript-typescript
47+
build-mode: none
48+
- language: python
49+
build-mode: none
50+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
51+
# Use `c-cpp` to analyze code written in C, C++ or both
52+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
53+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
54+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
55+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
56+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
57+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v4
61+
62+
# Initializes the CodeQL tools for scanning.
63+
- name: Initialize CodeQL
64+
uses: github/codeql-action/init@v3
65+
with:
66+
languages: ${{ matrix.language }}
67+
build-mode: ${{ matrix.build-mode }}
68+
# If you wish to specify custom queries, you can do so here or in a config file.
69+
# By default, queries listed here will override any specified in a config file.
70+
# Prefix the list here with "+" to use these queries and those in the config file.
71+
72+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
73+
# queries: security-extended,security-and-quality
74+
75+
# If the analyze step fails for one of the languages you are analyzing with
76+
# "We were unable to automatically build your code", modify the matrix above
77+
# to set the build mode to "manual" for that language. Then modify this step
78+
# to build your code.
79+
# ℹ️ Command-line programs to run using the OS shell.
80+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
81+
- if: matrix.build-mode == 'manual'
82+
shell: bash
83+
run: |
84+
echo 'If you are using a "manual" build mode for one or more of the' \
85+
'languages you are analyzing, replace this with the commands to build' \
86+
'your code, for example:'
87+
echo ' make bootstrap'
88+
echo ' make release'
89+
exit 1
90+
91+
- name: Perform CodeQL Analysis
92+
uses: github/codeql-action/analyze@v3
93+
with:
94+
category: "/language:${{matrix.language}}"
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
- demo
9+
- hotfix
10+
pull_request:
11+
types:
12+
- opened
13+
- ready_for_review
14+
- reopened
15+
- synchronize
16+
branches:
17+
- main
18+
- dev
19+
- demo
20+
- hotfix
21+
workflow_dispatch:
22+
23+
jobs:
24+
build-and-push:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v2
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v1
33+
34+
- name: Log in to Azure Container Registry
35+
if: ${{ github.ref_name == 'main' }}
36+
uses: azure/docker-login@v2
37+
with:
38+
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
39+
username: ${{ secrets.ACR_USERNAME }}
40+
password: ${{ secrets.ACR_PASSWORD }}
41+
42+
- name: Log in to Azure Container Registry (Dev/Demo)
43+
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
44+
uses: azure/docker-login@v2
45+
with:
46+
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
47+
username: ${{ secrets.ACR_DEV_USERNAME }}
48+
password: ${{ secrets.ACR_DEV_PASSWORD }}
49+
50+
- name: Set Docker image tag
51+
run: |
52+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
53+
echo "TAG=latest" >> $GITHUB_ENV
54+
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
55+
echo "TAG=dev" >> $GITHUB_ENV
56+
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
57+
echo "TAG=demo" >> $GITHUB_ENV
58+
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then
59+
echo "TAG=hotfix" >> $GITHUB_ENV
60+
fi
61+
- name: Build and push Docker images
62+
if: ${{ github.ref_name == 'main' }}
63+
run: |
64+
cd src/backend
65+
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \
66+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \
67+
echo "Backend image built and pushed successfully."
68+
cd ../frontend
69+
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \
70+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \
71+
echo "Frontend image built and pushed successfully."
72+
- name: Build and push Docker images (Dev/Demo/hotfix)
73+
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
74+
run: |
75+
cd src/backend
76+
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \
77+
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \
78+
echo "Dev/Demo/Hotfix Backend image built and pushed successfully."
79+
cd ../frontend
80+
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \
81+
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \
82+
echo "Dev/Demo/Hotfix Frontend image built and pushed successfully."
83+

.github/workflows/pylint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Pylint and Flake8
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.11"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v3
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r src/backend/requirements.txt
23+
pip install flake8 # Ensure flake8 is installed explicitly
24+
25+
- name: Run flake8 and pylint
26+
run: |
27+
flake8 --config=.flake8 src/backend # Specify the directory to lint

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Test Workflow with Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
- demo
9+
- hotfix
10+
pull_request:
11+
types:
12+
- opened
13+
- ready_for_review
14+
- reopened
15+
- synchronize
16+
branches:
17+
- main
18+
- main
19+
- dev
20+
- demo
21+
- hotfix
22+
23+
jobs:
24+
test:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v3
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: '3.11'
35+
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -r src/backend/requirements.txt
40+
pip install pytest-cov
41+
42+
- name: Check if test files exist
43+
id: check_tests
44+
run: |
45+
if [ -z "$(find src -type f -name 'test_*.py')" ]; then
46+
echo "No test files found, skipping tests."
47+
echo "skip_tests=true" >> $GITHUB_ENV
48+
else
49+
echo "Test files found, running tests."
50+
echo "skip_tests=false" >> $GITHUB_ENV
51+
fi
52+
53+
- name: Run tests with coverage
54+
if: env.skip_tests == 'false'
55+
run: |
56+
pytest --cov=. --cov-report=term-missing --cov-report=xml
57+
58+
- name: Skip coverage report if no tests
59+
if: env.skip_tests == 'true'
60+
run: |
61+
echo "Skipping coverage report because no tests were found."

0 commit comments

Comments
 (0)