Skip to content

Commit afd245f

Browse files
authored
Merge pull request #5 from karimzakzouk/Testing
Testing
2 parents c7ea029 + 5a9d80d commit afd245f

25 files changed

+333
-4289
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,36 @@ jobs:
1818
name: Unit Testing
1919
strategy:
2020
matrix:
21-
node-version: [18, 19, 20]
21+
python-version: [3.9, 3.10, 3.11]
2222
os: [ubuntu-latest, windows-latest, macos-latest]
2323
exclude:
2424
- os: windows-latest
25-
node-version: 18
25+
python-version: 3.9
2626
runs-on: ${{ matrix.os }}
2727

2828
steps:
2929
- name: Checkout Repository
3030
uses: actions/checkout@v5
3131

32-
- name: Setup NodeJS Version - ${{ matrix.node-version }}
33-
uses: actions/setup-[email protected]
32+
- name: Setup Puthon Version - ${{ matrix.python-version }}
33+
uses: actions/setup-python@v5
3434
with:
35-
node-version: ${{ matrix.node-version }}
35+
python-version: ${{ matrix.python-version }}
3636

3737
- name: Install Dependencies
38-
run: npm install
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install pytest pytest-cov
3941
4042
- name: Unit Testing
41-
id: Nodejs-unit-testing-step
42-
run: npm test
43+
id: Python-unit-testing-step
44+
run: pytest --junitxml=test-results.xml
4345

4446
- name: Archive Test Result
4547
if: always()
4648
uses: actions/upload-artifact@v4
4749
with:
48-
name: Mocha-Test-Result-${{ matrix.os }}-${{ matrix.node-version }}
50+
name: Mocha-Test-Result-${{ matrix.os }}-${{ matrix.python-version }}
4951
path: test-results.xml
5052
retention-days: 1
5153

@@ -59,18 +61,20 @@ jobs:
5961
- name: Checkout Repository
6062
uses: actions/checkout@v5
6163

62-
- name: Setup NodeJS
63-
uses: actions/setup-[email protected]
64+
- name: Setup Python
65+
uses: actions/setup-python@v5
6466
with:
65-
node-version: 18
67+
python-version: "3.10"
6668

6769
- name: Install Dependencies
68-
run: npm install
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install pytest pytest-cov
6973
7074
- name: Run Code Coverage
7175
id: coverage
7276
continue-on-error: true
73-
run: npm run coverage
77+
run: pytest --cov=. --cov-report=xml --cov-report=html
7478

7579
- name: Archive Coverage Report
7680
if: always()

.github/workflows/docker.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: docker/login-action@v3
2727
with:
2828
registry: ghcr.io
29-
username: ${{ github.actor }}
29+
username: ${{ github.repository_owner }}
3030
password: ${{ secrets.GITHUB_TOKEN }}
3131

3232
- name: Build and push Docker image
@@ -94,10 +94,19 @@ jobs:
9494
run: |
9595
sed -i "s|repository: .*|repository: docker.io/${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}|g" ./helm/values.yaml
9696
sed -i "s|tag: .*|tag: ${{ github.sha }}|g" ./helm/values.yaml
97-
- name: Commit updated image tag
97+
98+
- name: Push Helm chart to separate repo
9899
run: |
99-
git config --local user.email "[email protected]"
100-
git config --local user.name "GitHub Action"
101-
git add helm/values.yaml
102-
git commit -m "Update image tag to ${{ github.sha }}" || exit 0
103-
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
100+
git clone https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository_owner }}/helm.git helm-repo
101+
cd helm-repo
102+
103+
# Copy updated helm folder into this repo
104+
rm -rf *
105+
cp -r ../helm/* .
106+
107+
# Commit and push changes
108+
git config user.email "[email protected]"
109+
git config user.name "GitHub Action"
110+
git add .
111+
git commit -m "Update helm chart with image ${{ github.sha }}" || echo "No changes to commit"
112+
git push origin main

.github/workflows/main-pipeline.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ jobs:
6767
with:
6868
filters: |
6969
app:
70-
- 'app-controllers/**'
71-
- 'app-test.js'
72-
- 'app.js'
70+
- 'app_test.py'
71+
- 'app.py'
7372
- 'index.html'
7473
- 'Dockerfile'
75-
- 'package*.json'
76-
- 'images/**'
74+
- 'static/**'
7775
- '.github/workflows/ci.yml'
7876
- '.github/workflows/docker.yml'
7977
infra:
@@ -256,4 +254,4 @@ jobs:
256254
image_tag: ${{ github.sha }}
257255
permissions:
258256
contents: read
259-
id-token: write
257+
id-token: write

Dockerfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
FROM node:18-alpine3.17
2-
1+
FROM python:3.11-alpine3.17
32
WORKDIR /usr/app
4-
5-
COPY package*.json /usr/app/
6-
7-
RUN npm install
8-
3+
COPY requirements.txt /usr/app/
4+
RUN pip install -r requirements.txt
95
COPY . .
10-
116
EXPOSE 3000
12-
13-
CMD [ "npm", "start" ]
7+
CMD [ "python", "app.py" ]

app-controller.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)