Integrate and deploy #282
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integrate and deploy | |
on: | |
pull_request: | |
env: | |
REDIS_URL: redis@redis | |
jobs: | |
well-written-test: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout HEAD | |
uses: actions/checkout@v2.4.0 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install . | |
pip install mypy flake8 pytest pytest-cov | |
- name: Test with mypy | |
run: mypy tests/ mentor_match_web/app/ --ignore-missing-imports | |
- name: Test with flake8 | |
run: flake8 --max-line-length=131 --extend-ignore=E203 tests/ mentor_match_web/app/ | |
get-commit-tag: | |
needs: well-written-test | |
runs-on: ubuntu-20.04 | |
outputs: | |
image_commit_tag: ${{ steps.vars.outputs.image_commit_tag }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: Declare some variables | |
id: vars | |
shell: bash | |
run: | | |
echo "::set-output name=image_commit_tag::$(git rev-parse --short HEAD)" | |
test-and-push: | |
needs: | |
- get-commit-tag | |
env: | |
ENV: integration | |
GH_IMAGE_COMMIT_TAG: ${{ needs.get-commit-tag.outputs.image_commit_tag }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout HEAD | |
uses: actions/checkout@v2.4.0 | |
- name: Install docker-compose | |
if: ${{ env.ACT }} | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
- name: Compose environment | |
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d | |
- name: Install test dependencies | |
run: docker-compose exec -T app poetry install --with test | |
- name: Full test suite | |
run: docker-compose exec -T app poetry run pytest tests -n 3 --cache-clear --cov=app tests/ > pytest-coverage.txt | |
- name: Stop docker | |
if: ${{ env.ACT }} | |
run: docker-compose down | |
- name: tag images | |
run: | | |
export WEB_IMAGE=web:${GH_IMAGE_COMMIT_TAG} | |
export WORKER_IMAGE=worker:${GH_IMAGE_COMMIT_TAG} | |
docker tag ${WEB_IMAGE} ghcr.io/jonodrew/mentor-match/${WEB_IMAGE} | |
docker tag ${WEB_IMAGE} ghcr.io/jonodrew/mentor-match/web:latest | |
docker tag ${WORKER_IMAGE} ghcr.io/jonodrew/mentor-match/${WORKER_IMAGE} | |
docker tag ${WORKER_IMAGE} ghcr.io/jonodrew/mentor-match/worker:latest | |
- name: log in to registries | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Push images | |
run: | | |
docker image push --all-tags ghcr.io/jonodrew/mentor-match/web | |
docker image push --all-tags ghcr.io/jonodrew/mentor-match/worker |