Skip to content

[2025-01-30 17:12] Partial CDS update #68

[2025-01-30 17:12] Partial CDS update

[2025-01-30 17:12] Partial CDS update #68

name: Release Candidate evaluation
on:
push:
branches:
release-*
jobs:
# ---------------------------------------------------------------- #
# | Coverage and SonarCloud.io upload | #
# ---------------------------------------------------------------- #
tests-and-sonarcloud:
strategy:
matrix:
version: ["3.10", "3.11"] # TODO: Get Python versions from the project
name: Testing and updating SonarCloud
runs-on: ubuntu-latest
steps:
# Checkout
- name: Branch checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# Install Python
- name: Setup Python installation
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
# Install Poetry
- name: Setup Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry self update --preview
echo "$HOME/.local/bin" >> $GITHUB_PATH
# Install required dependencies
- name: Install dependencies
run: poetry install -v --with dev
# Run Coverage
- name: Run Coverage
run: |
poetry run coverage run -m pytest
poetry run coverage report
# Generate XML Coverage result file
- if: matrix.version == '3.10'
name: Generate Coverage XML file
run: poetry run coverage xml
# Upload coverage data to SonarCloud.io
- if: matrix.version == '3.10'
name: Update SonarCloud.io
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# ---------------------------------------------------------------- #
# | Build image and upload it to AWS and DockerHub | #
# ---------------------------------------------------------------- #
create-and-upload-image:
name: Create and upload image
needs: tests-and-sonarcloud
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment:
name: ci
steps:
# Checkout
- name: Check out source code
uses: actions/checkout@v3
# Configure AWS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: arn:aws:iam::325973380531:role/dnb-inno-repository-access-role
aws-region: eu-central-1
# Install Poetry (needed for version)
- name: Setup Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry self update --preview
echo "$HOME/.local/bin" >> $GITHUB_PATH
# Login to Amazon ECR
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Determine current version
run: |
version="$(poetry version --short)rc${{ github.run_number }}"
echo "Package version: $version"
echo "package_version=$version" >> $GITHUB_ENV
# Create the image and upload it to Amazon ECR
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: 325973380531.dkr.ecr.eu-central-1.amazonaws.com
ECR_REPOSITORY: dnb-inno-image-repository
run: |
docker build --target gunicorn-image -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_RC }}:${{ env.package_version }} .
docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_RC }}:${{ env.package_version }}
docker build -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_RC }} .
docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_RC }}