-
Notifications
You must be signed in to change notification settings - Fork 14
125 lines (106 loc) · 4.09 KB
/
rabbit_consumer.yaml
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
115
116
117
118
119
120
121
122
123
124
125
name: Rabbit Consumer
on:
push:
branches:
- master
pull_request:
paths:
- ".github/workflows/rabbit_consumer.yaml"
- "OpenStack-Rabbit-Consumer/**"
jobs:
test_and_lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Required for requests-kerberos
sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install libkrb5-dev
pip install -r OpenStack-Rabbit-Consumer/requirements.txt
pip install -r OpenStack-Rabbit-Consumer/requirements-test.txt
- name: Run tests
# Using Python3 to launch the module sets up the Python path for us
run: cd OpenStack-Rabbit-Consumer && python3 -m coverage run -m pytest .
- name: Analyse with pylint
run: |
cd OpenStack-Rabbit-Consumer && pylint --recursive yes rabbit_consumer test
- name: Prepare coverage
run: |
cd OpenStack-Rabbit-Consumer && python -m coverage xml
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
files: OpenStack-Rabbit-Consumer/coverage.xml
fail_ci_if_error: true
flags: rabbit_consumer
push_dev_image_harbor:
runs-on: ubuntu-latest
needs: test_and_lint
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Harbor
uses: docker/login-action@v2
with:
registry: harbor.stfc.ac.uk
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: Set commit SHA for later
id: commit_sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push to staging project
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
context: "{{defaultContext}}:OpenStack-Rabbit-Consumer"
tags: "harbor.stfc.ac.uk/stfc-cloud-staging/openstack-rabbit-consumer:${{ steps.commit_sha.outputs.sha_short }}"
- name: Inform of tagged name
run: echo "Image published to harbor.stfc.ac.uk/stfc-cloud-staging/openstack-rabbit-consumer:${{ steps.commit_sha.outputs.sha_short }}"
push_release_image_harbor:
runs-on: ubuntu-latest
needs: test_and_lint
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Harbor
uses: docker/login-action@v2
with:
registry: harbor.stfc.ac.uk
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: Get release tag for later
id: release_tag
run: echo "version=$(cat OpenStack-Rabbit-Consumer/version.txt)" >> $GITHUB_OUTPUT
- name: Check if release file has updated
uses: dorny/paths-filter@v2
id: release_updated
with:
filters: |
version:
- 'OpenStack-Rabbit-Consumer/version.txt'
- name: Build and push on version change
uses: docker/build-push-action@v3
if: steps.release_updated.outputs.version == 'true'
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
context: "{{defaultContext}}:OpenStack-Rabbit-Consumer"
tags: "harbor.stfc.ac.uk/stfc-cloud/openstack-rabbit-consumer:v${{ steps.release_tag.outputs.version }}"
- name: Inform of tagged name
if: steps.release_updated.outputs.version == 'true'
run: echo "Image published to harbor.stfc.ac.uk/stfc-cloud/openstack-rabbit-consumer:v${{ steps.release_tag.outputs.version }}"