Skip to content

style: improve the CI code #43

style: improve the CI code

style: improve the CI code #43

# ===================================================================================== #
# GitHub Actions configuration file for an AWS Glue ETL application #
# #
# This workflow will: #
# 1. Install dependencies, run tests and style checks with a variety of Python #
# versions. #
# 2. Copy the Glue scripts to an appropriate S3 bucket. #
# ===================================================================================== #
name: on PR against [dev]
on:
pull_request:
branches: [dev]
paths-ignore:
- ".github/workflows/on-iac-*.yaml"
- "infrastructure/**"
jobs:
# ===================================================================================== #
# PYTHON TESTS AND STYLE CHECKS #
# ===================================================================================== #
python-test-and-style-check:
environment: quality-assurance
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@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
- name: Run unit tests with pytest
run: pytest
- name: Comment unit test coverage
uses: MishaKav/pytest-coverage-comment@v1.1.43
with:
junitxml-path: ./pytest-junit.xml
pytest-xml-coverage-path: ./coverage.xml
- name: Run isort to check Python import order
run: isort --check --profile black ./src ./tests
- name: Run Black to check the Python code style and quality
run: black --check ./src ./tests
- name: Run Flake8 to check the Python code style and quality
run: flake8 ./src ./tests
# ===================================================================================== #
# GLUE JOBS DEPLOYMENT #
# ===================================================================================== #
glue-jobs-deployment:
environment: quality-assurance
needs: python-test-and-style-check
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GlueCICDGitHubActionsServiceRole
aws-region: ${{ vars.AWS_REGION }}
- name: Copy Glue scripts to S3
run: aws s3 sync --delete ./src s3://${{ vars.GLUE_SCRIPTS_S3_BUCKET }}