Skip to content

debug-1

debug-1 #30

Workflow file for this run

name: CICD
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
cd tests/unit/
pytest -v --cov
integration-test:
needs: unit-test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
env:
ENV: TEST
DATABASE_URL: postgresql+psycopg2://postgres:1234@localhost:5432/test
run: |
cd tests/integration/
pytest -v --cov
deploy-infrastructure:
needs: integration-test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Deploy CloudFormation stack
run: |
aws cloudformation deploy \
--template-file infrastructure/cf.yml \
--stack-name test-stack \
--no-fail-on-empty-changeset \
build-and-push-image:
needs: deploy-infrastructure
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: test
IMAGE_TAG: latest
run: |
# IMAGE_URI="${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG}"
echo $ECR_REGISTRY
ehco $ECR_REPOSITORY
echo $IMAGE_TAG
# docker build -t $IMAGE_NAME .
# docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_URI
# docker push $IMAGE_URI
# run: |
# ECR_REPOSITORY=test
# IMAGE_TAG=latest
# IMAGE_NAME=app
# IMAGE_URI="${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG}"
# docker build -t $IMAGE_NAME .
# docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_URI
# docker push $IMAGE_URI