Skip to content

Commit

Permalink
Update GitHub client to allow direct commits to main (#8)
Browse files Browse the repository at this point in the history
* Remove obsolete Lambda packaging script and related configuration files

- Deleted `package_lambda.py` script responsible for packaging AWS Lambda functions and layers.
- Removed `pip.conf` configuration file for pip settings.
- Eliminated `requirements.txt` file that specified Python dependencies.
- Deleted `test_payload.json` used for testing Lambda functions.
- Removed empty JSON and TFVAR files in `varfiles` directory.
- Deleted `variables.tf` file containing Terraform variable definitions.
- Removed `versions.tf` file specifying Terraform version requirements.
- Added new GitHub Actions workflow for building and pushing Lambda container images using Packer.
- Introduced `packer.pkr.hcl` file for Packer configuration to build Docker images for Lambda.

* Refactor GitHub API integration to remove Census-specific references and improve configuration handling

* Update Python setup in build workflow to use actions/setup-python@v4 and improve dependency installation

* Add Terraform backend configuration for GCS storage

* Add GOOGLE_CREDENTIALS environment variable to build workflow

* Remove unused PACKER_GITHUB_API_TOKEN from build workflow environment

* updating build

* Remove eks_automation/data.json configuration file

* Add integration tests and workflow

* Resolve merge conflicts after merging main

* Add integration tests workflow and variables config

* Remove __pycache__ directories and add .gitignore

* Update GitHub client to allow direct commits to main

- Add auto_init and branch settings in repository creation
- Improve branch-specific operations in clone and commit methods
- Fix test cases to properly test branch operations
- Remove version-specific file cloning in favor of branch-based

* Ensure target directory exists when downloading repository files

* Enhance GitHubClient to ensure target directory exists and handle unexpected blob encoding

* Add delay in integration tests to ensure GitHub API consistency

---------

Co-authored-by: Dave Arnold <dave@roknsound.com>
  • Loading branch information
2 people authored and GitHub committed Apr 17, 2025
1 parent fb759b1 commit 53039e3
Show file tree
Hide file tree
Showing 18 changed files with 1,086 additions and 300 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches: [ "main" ]

permissions:
contents: write
id-token: write
Expand All @@ -13,6 +13,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Integration Tests

on:
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
integration-tests:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: eks_automation/requirements.txt

- name: Install dependencies
run: |
cd eks_automation
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run integration tests
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_API: "https://api.github.com" # Can be overridden with vars if needed
GITHUB_ORG: ${{ github.repository_owner }}
run: |
cd eks_automation
python -m pytest tests/ -v -m integration
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Python
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
dist/
build/
*.egg-info/

# Virtual Environment
venv/
env/
.env/

# IDE
.idea/
.vscode/

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
coverage.xml
*.cover
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.PHONY: install test test-unit test-integration clean

# Variables
PYTHON = python3
PIP = $(PYTHON) -m pip
PYTEST = $(PYTHON) -m pytest
REQUIREMENTS = eks_automation/requirements.txt
TEST_DIR = eks_automation/tests
UNIT_TEST_FILE = $(TEST_DIR)/test_github_client.py
INTEGRATION_TEST_FILE = $(TEST_DIR)/test_github_client_integration.py

# Default target
all: test

# Install dependencies
install:
$(PIP) install -r $(REQUIREMENTS)

# Run all tests
test: test-unit test-integration
@echo "Running all tests..."
$(PYTEST) $(TEST_DIR)

# Run unit tests
test-unit:
@echo "Running unit tests..."
$(PYTEST) $(UNIT_TEST_FILE)

# Run integration tests
test-integration:
@echo "Running integration tests..."
$(PYTEST) $(INTEGRATION_TEST_FILE)

# Clean up Python cache files
clean:
find . -type f -name '*.pyc' -delete
find . -type d -name '__pycache__' -exec rm -rf {} +
rm -rf .pytest_cache
rm -rf .coverage
Loading

0 comments on commit 53039e3

Please sign in to comment.