Skip to content

Merge pull request #901 from alphagov/1893-fix-test #641

Merge pull request #901 from alphagov/1893-fix-test

Merge pull request #901 from alphagov/1893-fix-test #641

name: Deploy to test
on:
push:
branches:
- dev
jobs:
test:
name: Unit tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Unit tests
run: |
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements_for_test.txt
export DB_SECRET="{'dbClusterIdentifier':'none','password':'secret','dbname':'accessibility_monitoring_app','engine':'postgres','port':5432,'host':'localhost','username':'admin'}"
export DB_NAME=bucket-name
export ALLOWED_HOSTS='localhost 127.0.0.1 0.0.0.0'
export SECRET_KEY=1234
export DEBUG=TRUE
npm i
make static_files_process
make test
int-test:
needs: test
name: Integration tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Integration tests
run: |
cd stack_tests/integration_tests
docker compose up --abort-on-container-exit
deploy:
needs: int-test
name: Deploy to AWS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install AWS Copilot
run: |
mkdir -p $GITHUB_WORKSPACE/bin
# download copilot
# curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x copilot && sudo mv copilot /usr/local/bin/copilot && copilot --help
curl -Lo copilot-linux https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && \
# make copilot bin executable
sudo chmod +x copilot-linux && \
# move to path
sudo mv copilot-linux $GITHUB_WORKSPACE/bin/copilot && \
# add to PATH
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Deploy to AWS
run: |
copilot svc deploy --name viewer-svc --env testenv && \
copilot svc deploy --name amp-svc --env testenv
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_COPILOT }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_COPILOT }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION_COPILOT }}
- name: Smoke tests
run: |
docker compose --file stack_tests/smoke_tests/test-platform.docker-compose.yml up --abort-on-container-exit && \
docker compose --file stack_tests/smoke_tests_viewer/test-viewer.docker-compose.yml up --abort-on-container-exit
env:
SMOKE_TESTS_USERNAME: ${{ secrets.SMOKE_TESTS_USERNAME }}
SMOKE_TESTS_PASSWORD: ${{ secrets.SMOKE_TESTS_PASSWORD }}