ci: add type checks #80
Workflow file for this run
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: proWES checks | |
on: | |
push: | |
branches: [ dev ] | |
pull_request: | |
branches: [ dev ] | |
jobs: | |
lint: | |
name: Run static code analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install requirements | |
run: | | |
pip install -r requirements_dev.txt | |
pip install . | |
- name: Lint with Flake8 | |
run: flake8 | |
- name: Lint with Pylint | |
run: pylint pro_wes/ setup.py | |
- name: Check code format with Black | |
run: black --check setup.py pro_wes/ tests/ | |
- name: Check types with mypy | |
run: mypy setup.py pro_wes/ | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
env: | |
PROBE_ENDPOINT: localhost:8090/ga4gh/wes/v1/service-info | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Deploy app | |
run: docker-compose up -d --build | |
- name: Wait for app startup | |
run: sleep 20 | |
- name: Probe endpoint | |
run: | | |
test $( \ | |
curl \ | |
-sL \ | |
-v \ | |
-o /dev/null \ | |
-w '%{http_code}' \ | |
-X GET \ | |
--header 'Accept: application/json' \ | |
"${PROBE_ENDPOINT}" \ | |
) == '200' || exit 1 | |
publish: | |
name: Build and publish app image | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'push' }} | |
needs: [lint, test] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Generate tag | |
run: | | |
echo "TAG=$(date '+%Y%m%d')" >> $GITHUB_ENV | |
- name: Build and publish image | |
id: docker | |
uses: philips-software/[email protected] | |
with: | |
dockerfile: . | |
image-name: "prowes" | |
tags: "latest ${{ env.TAG }}" | |
push-branches: "${{ github.event.repository.default_branch }}" | |
env: | |
REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_LOGIN }} | |
REGISTRY_TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}" | |
DOCKER_ORGANIZATION: ${{ secrets.DOCKERHUB_ORG }} | |
GITHUB_ORGANIZATION: ${{ github.repository_owner }} | |
- name: Verify that image was pushed | |
run: | | |
echo "Push indicator: ${{ steps.docker.outputs.push-indicator }}" | |
echo "# Set to 'true' if image was pushed, empty string otherwise" | |
test "${{ steps.docker.outputs.push-indicator }}" == "true" |