Update main.yml #46
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
# comprehensive github action yml reference: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions | |
--- | |
name: CI | |
on: | |
push: # any push event to master will trigger this | |
branches: ["master"] | |
pull_request: # any pull request to master will trigger this | |
branches: ["master"] | |
workflow_dispatch: # allows you to manually trigger run | |
jobs: | |
tests-on-linux: | |
name: "${{ matrix.os }} Python ${{ matrix.python-version }}" | |
runs-on: "${{ matrix.os }}" # for all available VM runtime, see this: https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres:15.7-alpine # docker run --rm --name test-psql-db -p 43347:5432 -e POSTGRES_PASSWORD=password -d postgres:10.6-alpine | |
# Provide the password for postgres | |
env: | |
POSTGRES_PASSWORD: password | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host 43347 | |
- 40311:5432 | |
env: # define environment variables | |
USING_COVERAGE: "3.8,3.9,3.10,3.11" | |
strategy: | |
matrix: | |
os: ["ubuntu-latest"] | |
# os: ["ubuntu-latest"] # for temp testing only | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
# python-version: ["3.6"] # for temp testing only | |
steps: | |
- uses: "actions/checkout@v3" # https://github.com/marketplace/actions/checkout | |
- uses: "actions/setup-python@v4" # https://github.com/marketplace/actions/setup-python | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- name: "Install dependencies on MacOS or Linux" | |
run: | | |
set -xe | |
python -VV | |
python -m site | |
python -m pip install --upgrade pip setuptools wheel virtualenv codecov | |
pip install . | |
pip install -r requirements-test.txt | |
- name: "Run pytest" | |
run: "python -m pytest tests --cov=sqlalchemy_mate" | |
- name: "Upload coverage to Codecov" | |
if: "contains(env.USING_COVERAGE, matrix.python-version)" | |
uses: "codecov/codecov-action@v3" # https://github.com/marketplace/actions/codecov-action | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: MacHu-GWU/sqlalchemy_mate-project | |
fail_ci_if_error: true | |
tests-on-windows: | |
name: "${{ matrix.os }} Python ${{ matrix.python-version }}" | |
runs-on: "${{ matrix.os }}" # for all available VM runtime, see this: https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners | |
env: # define environment variables | |
USING_COVERAGE: "3.8,3.9,3.10,3.11" | |
strategy: | |
matrix: | |
os: ["windows-latest"] | |
# os: ["ubuntu-latest"] # for temp testing only | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
# python-version: ["3.6"] # for temp testing only | |
exclude: | |
- os: windows-latest # this is a useless exclude rules for demonstration use only | |
python-version: 2.7 | |
steps: | |
- uses: "actions/checkout@v3" # https://github.com/marketplace/actions/checkout | |
- uses: "actions/setup-python@v4" # https://github.com/marketplace/actions/setup-python | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- if: matrix.os == 'windows-latest' # for condition steps, you should put if at begin, and use single quote for logical expression, this line is not necessary at all, but I intentionally leave it here to demonstrate the right conditional step syntax | |
name: "Install dependencies on Windows" | |
run: | | |
python -m site | |
python -m pip install --upgrade pip setuptools wheel virtualenv codecov | |
pip install . | |
pip install -r requirements-test.txt | |
- name: "Run pytest" | |
run: "python -m pytest tests --cov=sqlalchemy_mate" | |
- name: "Upload coverage to Codecov" | |
if: "contains(env.USING_COVERAGE, matrix.python-version)" | |
uses: "codecov/codecov-action@v3" # https://github.com/marketplace/actions/codecov-action | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: MacHu-GWU/sqlalchemy_mate-project | |
fail_ci_if_error: true |