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

add rabbit-consumer source code #89

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/build_images.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: docker_images
on:
push:
paths-ignore:
- 'cloud-chatops/**'
- '.github/workflows/cloud_chatops.yaml'
paths:
- 'notebooks/**'
- '.github/workflows/codeql.yaml'
- '.github/workflows/build_images.yaml'
pull_request:
paths-ignore:
- 'cloud-chatops/**'
- '.github/workflows/cloud_chatops.yaml'
paths:
- 'notebooks/**'
- '.github/workflows/codeql.yaml'
- '.github/workflows/build_images.yaml'
schedule: [{cron: "14 14 * * TUE"}] # Every Tuesday at 14:14
jobs:
setup:
Expand Down Expand Up @@ -54,7 +56,7 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Harbor
- name: Login to Harbor Staging
if: ${{ github.ref != 'refs/heads/master' }}
uses: docker/login-action@v3
with:
Expand Down
File renamed without changes.
126 changes: 126 additions & 0 deletions .github/workflows/rabbit_consumer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
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 $(git ls-files '*.py')

- 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
token: ${{secrets.CODECOV_TOKEN}}

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.STAGING_HARBOR_USERNAME }}
password: ${{ secrets.STAGING_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 }}"
File renamed without changes.
File renamed without changes.
Loading
Loading