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

Github Action Update Test 1 #11

Merged
merged 14 commits into from
Jul 12, 2024
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
99 changes: 47 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,60 @@ on:
branches: [ main ]

jobs:
unit-tests:
build-and-deploy-infra:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8, 3.9]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install boto3 botocore pytest
- name: Configure 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: eu-west-1

- name: Run tests
- name: Setup SAM CLI
uses: aws-actions/setup-sam@v1

- name: Run sam build
run: sam build

- name: Run sam deploy
run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset

- name: Debug Environment Variables
run: env | grep AWS

- name: Configure AWS credentials for S3 Sync
run: |
pytest tests/unit/test_lambda_functions.py
mkdir -p ~/.aws
echo "[default]" > ~/.aws/credentials
echo "aws_access_key_id = ${{ secrets.AWS_ACCESS_KEY_ID }}" >> ~/.aws/credentials
echo "aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials
echo "[default]" > ~/.aws/config
echo "region = eu-west-1" >> ~/.aws/config

- name: Debug secrets
run: |
echo "AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}"
echo "AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}"
- name: Sync resume-site to S3
uses: jakejarvis/[email protected]
with:
args: --acl public-read --follow-symlinks --delete
env:
SOURCE_DIR: 'resume-site'
AWS_S3_BUCKET: 'recreated-website2351'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-1

build-and-deploy-infra:
needs: unit-tests
playwright-tests:
needs: build-and-deploy-infra
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9] # Ensure this job only runs with Python 3.9

steps:
- name: Checkout code
Expand All @@ -51,38 +69,15 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: 3.9

- name: Ensure Python 3.9 is on PATH
run: |
echo "Adding Python 3.9 to PATH"
echo "${{ steps.python-setup.outputs.python-location }}/bin" >> $GITHUB_PATH

- name: Verify Python version
run: |
python --version
which python

- name: Setup SAM CLI
uses: aws-actions/setup-sam@v1

- name: Configure 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: eu-west-1

- name: Run sam build
- name: Install dependencies
run: |
sam build
python -m pip install --upgrade pip
pip install pytest
pip install pytest-playwright
playwright install


- name: Run sam deploy
- name: Run Playwright tests
run: |
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset





pytest -v tests/playwright-tests
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# Cloud Resume Challenge
# AWS Serverless Application with CI/CD Pipeline - Cloud Resume Challenge

TODO - add
This is my attempt at the Cloud Resume Challenge https://cloudresumechallenge.dev/docs/the-challenge/aws/

## Table of Contents
This repository contains a serverless application built on AWS using Lambda functions, DynamoDB, and integrated with a CI/CD pipeline. It also includes Playwright for end-to-end testing and unit tests for Lambda functions.

TODO - add
## Benefits of the challenge
## Live Site
https://anthony-coughlin-resume.com/

TODO - add
## Challenge stages
## Technologies Used

### Stage 0-10
- **AWS Lambda:** Serverless compute service used for executing backend functions without provisioning or managing servers.

- **AWS DynamoDB:** Fully managed NoSQL database service for storing and retrieving data at scale with low latency.

- **CI/CD Pipeline:** Automated workflow for Continuous Integration and Continuous Deployment (CI/CD) using GitHub Actions.

- **Playwright:** End-to-end testing framework for web applications to ensure application quality and reliability.

- **Unit Tests:** Tests written using Python's `pytest` framework to validate individual Lambda function behavior and logic.

TODO - add
## CI/CD Pipeline

The CI/CD pipeline automates the testing, building, and deployment processes:

- **Unit Tests:** Run against Lambda functions to ensure expected behavior.

- **Build and Deploy:** Uses AWS SAM CLI to build and deploy Lambda functions and associated AWS resources. The site is also auto deployed and Playwright Tests are executed afterwards.
Loading