Skip to content

CI

CI #3249

Workflow file for this run

# Main python test suite for cgap-portal
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
name: cgap-portal tests
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# Build matrix
strategy:
matrix:
test_type: ['UNIT', 'INDEX', 'DOCKER']
# We are really not set up for these next two to be multiplicative, so be careful adding more.
python_version: ['3.11']
node_version: ['18']
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
# Per doc for node install at https://github.com/actions/setup-node#usage
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
check-latest: false
- name: Install/Link Postgres
if: ${{ matrix.test_type == 'UNIT' || matrix.test_type == 'INDEX' }}
run: |
sudo apt-get install curl ca-certificates gnupg
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql-14 postgresql-client-14
echo "/usr/lib/postgresql/14/bin" >> $GITHUB_PATH
sudo ln -s /usr/lib/postgresql/14/bin/initdb /usr/local/bin/initdb
- name: Install Deps
if: ${{ matrix.test_type == 'INDEX' || matrix.test_type == 'UNIT' }}
run: |
node --version
make build
- 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: us-east-1
- name: QA (UNIT)
if: ${{ matrix.test_type == 'UNIT' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
TEST_JOB_ID: cgap-unit-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
make remote-test-unit
make remote-test-npm
- name: Cleanup (UNIT)
if: ${{ always() && matrix.test_type == 'UNIT' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
TEST_JOB_ID: cgap-unit-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
poetry run wipe-test-indices $TEST_JOB_ID search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443
- name: QA (INDEX)
if: ${{ matrix.test_type == 'INDEX' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
TEST_JOB_ID: cgap-idx-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
make remote-test-indexing
- name: Cleanup (INDEX)
if: ${{ always() && matrix.test_type == 'INDEX' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
TEST_JOB_ID: cgap-idx-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
poetry run wipe-test-indices $TEST_JOB_ID search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443
- name: Docker Build
if: ${{ matrix.test_type == 'DOCKER' && matrix.node_version == '18' && matrix.python_version == '3.11' }}
run: |
touch deploy/docker/local/docker_development.ini # cheap substitute for prepare-docker to make ignored file
docker build .