-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (114 loc) · 4.64 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Producer Consumer CI Test
on:
push:
branches: ["dev"]
workflow_dispatch:
jobs:
load-dotenv:
runs-on: ubuntu-latest
outputs:
postgres-version-tag: ${{ steps.load-dotenv.outputs.POSTGRES_VERSION_TAG }}
postgres-port: ${{ steps.load-dotenv.outputs.POSTGRES_PORT }}
postgres-user: ${{ steps.load-dotenv.outputs.POSTGRES_USER }}
postgres-password: ${{ steps.load-dotenv.outputs.POSTGRES_PASSWORD }}
postgres-database: ${{ steps.load-dotenv.outputs.POSTGRES_DATABASE }}
rabbitmq-version-tag: ${{ steps.load-dotenv.outputs.RABBITMQ_VERSION_TAG }}
rabbitmq-port: ${{ steps.load-dotenv.outputs.RABBITMQ_PORT }}
rabbitmq-user: ${{ steps.load-dotenv.outputs.RABBITMQ_USER }}
rabbitmq-password: ${{ steps.load-dotenv.outputs.RABBITMQ_PASSWORD }}
queue-name: ${{ steps.load-dotenv.outputs.QUEUE_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load dotenv
id: load-dotenv
run: |
set -o allexport
source .env
set +o allexport
echo "POSTGRES_VERSION_TAG=$POSTGRES_VERSION_TAG" >> $GITHUB_OUTPUT
echo "POSTGRES_PORT=$POSTGRES_PORT" >> $GITHUB_OUTPUT
echo "POSTGRES_USER=$POSTGRES_USER" >> $GITHUB_OUTPUT
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $GITHUB_OUTPUT
echo "POSTGRES_DATABASE=$POSTGRES_DATABASE" >> $GITHUB_OUTPUT
echo "RABBITMQ_VERSION_TAG=$RABBITMQ_VERSION_TAG" >> $GITHUB_OUTPUT
echo "RABBITMQ_PORT=$RABBITMQ_PORT" >> $GITHUB_OUTPUT
echo "RABBITMQ_USER=$RABBITMQ_USER" >> $GITHUB_OUTPUT
echo "RABBITMQ_PASSWORD=$RABBITMQ_PASSWORD" >> $GITHUB_OUTPUT
echo "QUEUE_NAME=$QUEUE_NAME" >> $GITHUB_OUTPUT
test:
needs: load-dotenv
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
services:
rabbitmq:
image: rabbitmq:${{ needs.load-dotenv.outputs.rabbitmq-version-tag }}
env:
RABBITMQ_DEFAULT_USER: ${{ needs.load-dotenv.outputs.rabbitmq-user }}
RABBITMQ_DEFAULT_PASS: ${{ needs.load-dotenv.outputs.rabbitmq-password }}
options: >-
--health-cmd "rabbitmq-diagnostics -q check_running"
--health-interval 5s
--health-timeout 30s
--health-retries 3
ports:
- ${{ needs.load-dotenv.outputs.rabbitmq-port }}:5672
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
producer/requirements-dev.txt
consumer/requirements-dev.txt
- name: Install dependencies
run: |
pip install -r producer/requirements-dev.txt
pip install -r consumer/requirements-dev.txt
- name: Run tests
run: |
coverage run -m pytest -v producer/tests consumer/tests
coverage html
coverage report -m
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ needs.load-dotenv.outputs.postgres-port }}
POSTGRES_USER: ${{ needs.load-dotenv.outputs.postgres-user }}
POSTGRES_PASSWORD: ${{ needs.load-dotenv.outputs.postgres-password }}
POSTGRES_DATABASE: ${{ needs.load-dotenv.outputs.postgres-database }}
RABBITMQ_HOST: localhost
RABBITMQ_PORT: ${{ needs.load-dotenv.outputs.rabbitmq-port }}
RABBITMQ_USER: ${{ needs.load-dotenv.outputs.rabbitmq-user }}
RABBITMQ_PASSWORD: ${{ needs.load-dotenv.outputs.rabbitmq-password }}
QUEUE_NAME: ${{ needs.load-dotenv.outputs.queue-name }}
- name: upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./htmlcov/
- name: deploy to Github Pages
uses: actions/deploy-pages@v2
id: deployment
- name: Coverage Badge
uses: tj-actions/coverage-badge-py@v2
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v16
id: verify-changed-files
with:
files: coverage.svg
- name: Commit files
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add coverage.svg
git commit -m "Updated coverage.svg"
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}