Skip to content

show single file

show single file #126

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags:
- '**'
pull_request: {}
jobs:
server-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: '18.x'
- run: npm install
- run: npm run lint
- run: npm run build
cli-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: install
run: |
pip install -U pip
pip install -r requirements/cli.txt
- run: make lint
working-directory: cli
- run: make mypy
working-directory: cli
cli-test:
name: cli-test-${{ matrix.os }}-py${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos]
python-version: ['3.8', '3.9', '3.10', '3.11']
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install
run: |
pip install -U pip
pip install -r requirements/cli.txt
- run: pip freeze
- name: test
working-directory: cli
run: make test
- name: rename coverage
working-directory: cli
run: |
mkdir coverage
mv .coverage coverage/.coverage.${{ matrix.os }}-py${{ matrix.python-version }}
- name: store coverage files
uses: actions/upload-artifact@v3
with:
name: coverage
path: cli/coverage
cli-coverage-check:
# dogfooding! use smokeshow to view our coverage report
needs: [cli-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: get coverage files
uses: actions/download-artifact@v2
with:
name: coverage
path: cli
- run: pip install coverage smokeshow
- name: build coverage
working-directory: cli
run: |
coverage combine
coverage html -i
- run: smokeshow upload cli/htmlcov
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: CLI Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 90
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
deploy-cf-staging:
runs-on: ubuntu-latest
needs: [server-lint]
environment: cloudflare-staging-deploy
steps:
- uses: actions/checkout@v3
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: >
deploy
--var GITHUB_SHA:${{ github.sha }}
--var GITHUB_REF:${{ github.ref }}
--var POSTGREST_ROOT:${{ secrets.POSTGREST_ROOT }}
--var POSTGREST_APIKEY:${{ secrets.POSTGREST_APIKEY }}
check: # Used for branch protection
if: always()
needs: [server-lint, cli-lint, cli-test, cli-coverage-check, deploy-cf-staging]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
id: all-green
with:
jobs: ${{ toJSON(needs) }}
deploy-cf-prod:
if: "success() && github.ref == 'refs/heads/main'"
runs-on: ubuntu-latest
needs: [check]
environment: cloudflare-production-deploy
steps:
- uses: actions/checkout@v3
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: >
deploy
-e production
--var GITHUB_SHA:${{ github.sha }}
--var GITHUB_REF:${{ github.ref }}
--var POSTGREST_ROOT:${{ secrets.POSTGREST_ROOT }}
--var POSTGREST_APIKEY:${{ secrets.POSTGREST_APIKEY }}
release:
needs: [check]
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
environment: release-cli
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: install
run: pip install -U build
- name: check version
id: check-version
uses: samuelcolvin/check-python-version@v4
with:
version_file_path: 'cli/smokeshow/version.py'
- name: build
working-directory: cli
run: python -m build
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: cli/