From 564ce5d7d72b61db46839fdc32519ab27c6ac096 Mon Sep 17 00:00:00 2001 From: Vlad Gramuzov Date: Thu, 28 Nov 2024 13:15:07 +0100 Subject: [PATCH] update test workflow --- .github/workflows/ephemeral.yml | 89 -------------------------- .github/workflows/integration-test.yml | 2 +- .github/workflows/preview.yml | 35 ---------- .gitignore | 1 + Makefile | 2 + setup.cfg | 24 +++++++ setup.py | 4 ++ 7 files changed, 32 insertions(+), 125 deletions(-) delete mode 100644 .github/workflows/ephemeral.yml delete mode 100644 .github/workflows/preview.yml create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.github/workflows/ephemeral.yml b/.github/workflows/ephemeral.yml deleted file mode 100644 index 3333ac8..0000000 --- a/.github/workflows/ephemeral.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Deploy Redirect to GitHub Pages - -on: - schedule: - - cron: '0 * * * *' - workflow_dispatch: - -permissions: - contents: write - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set Up Git Configuration - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - - name: Set up Python 3.11 - id: setup-python - uses: actions/setup-python@v2 - with: - python-version: 3.11 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - name: Install AWS CLI - run: | - pip install awscli awscli-local - - - name: Run Ephemeral Script and Capture Output - run: | - OUTPUT=$(bash bin/ephemeral.sh 2>&1) - echo "$OUTPUT" - NEW_URL=$(echo "$OUTPUT" | grep -Eo 'https://ls-[^ ]+') - - if [ -z "$NEW_URL" ]; then - echo "Error: Failed to extract URL from script output." - exit 1 - fi - - echo "Extracted URL: $NEW_URL" - - echo "NEW_URL=$NEW_URL" >> $GITHUB_ENV - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - - name: Generate index.html with New Redirect URL - run: | - NEW_URL="${{ env.NEW_URL }}" - - # Validate the URL - if [[ ! "$NEW_URL" =~ ^https?:// ]]; then - echo "Error: Invalid URL provided." - exit 1 - fi - - echo "Redirecting to: $NEW_URL" - - cat > index.html < - - - - - Redirecting... - - -

If you are not redirected automatically, follow this link.

- - - EOL - - - name: Switch to gh-pages Branch and Commit Changes - run: | - git fetch origin gh-pages || echo "gh-pages branch does not exist; creating it." - git checkout gh-pages || git checkout --orphan gh-pages - git rm -rf . # Remove all files in the branch - git add index.html - git commit -m "Update redirect to ${NEW_URL}" - git push origin gh-pages --force diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 39ff947..3f62947 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -57,7 +57,7 @@ jobs: - name: Set up Dependencies run: | - pip install localstack requests boto3 pytest localstack-sdk-python awscli-local + make install pip install localstack-ci-extension-plugins/pytest_plugin cd localstack-ci-extension && pip install -e . && cd - diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index e3a888d..0000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: 'Create Preview on Pull Request' -on: - workflow_dispatch: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - localstack: - permissions: write-all - name: Setup LocalStack Preview - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: LocalStack Preview - uses: LocalStack/setup-localstack@v0.2.3 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - state-backend: ephemeral - state-action: start - include-preview: 'true' - install-awslocal: 'true' - extension-auto-install: 'localstack-extension-mailhog' - preview-cmd: | - pip install awscli awscli-local - bash bin/deploy.sh - bash bin/seed.sh - distributionId=$(awslocal cloudfront list-distributions | jq -r '.DistributionList.Items[0].Id'); - echo LS_PREVIEW_URL=$AWS_ENDPOINT_URL/cloudfront/$distributionId/ >> $GITHUB_ENV; - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} diff --git a/.gitignore b/.gitignore index e1a54cc..dfcbd3b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ develop-eggs/ dist/ .env .venv +*.egg-info/ env/ venv/ __pycache__ diff --git a/Makefile b/Makefile index 5df3609..ce932af 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +install: + pip install -e .; usage: ## Show usage for this Makefile @cat Makefile | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..4c7a0c7 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,24 @@ +[metadata] +name = serverless-quiz-app +version = 0.0.1 +url = localstack.cloud +author = LocalStack Team +author_email = info@localstack.cloud +description = LocalStack Quiz App +license = Proprietary +classifiers = + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + License :: Other/Proprietary License + Topic :: Software Development :: Testing + +[options] +zip_safe = False +packages = find_namespace: +install_requires = + localstack + requests + boto3 + pytest + localstack-sdk-python + awscli-local diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c823345 --- /dev/null +++ b/setup.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +from setuptools import setup + +setup()