Update dependency black to v24 #1346
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: CI/CD | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
env: | |
DEMO_BASE_URL_PREVIEW: dd-demo.vercel.app | |
DEMO_BASE_URL_PRODUCTION: datasette-dashboards-demo.vercel.app | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache Python modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade poetry | |
poetry install | |
- name: Run linting | |
run: | | |
poetry run black --check datasette_dashboards tests | |
poetry run flake8 datasette_dashboards tests | |
poetry run mypy --strict datasette_dashboards tests | |
- name: Run tests | |
run: | | |
poetry run pytest -v --cov=datasette_dashboards --cov=tests --cov-branch --cov-report=term-missing tests | |
poetry run coverage xml | |
- name: Publish code coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./coverage.xml | |
deploy-demo-setup: | |
name: Deployment setup | |
runs-on: ubuntu-latest | |
needs: test | |
outputs: | |
github_ref_slug: ${{ steps.output_step.outputs.github_ref_slug }} | |
deployment_url: ${{ steps.output_step.outputs.deployment_url }} | |
steps: | |
- name: Inject slug/short variables | |
uses: rlespinasse/github-slug-action@v5 | |
- name: Set preview deployment url variable | |
if: ${{ !contains(github.ref, 'master') && !contains(github.ref, 'tags') }} | |
run: echo "DEPLOYMENT_URL=https://${GITHUB_REF_SLUG_URL}-${DEMO_BASE_URL_PREVIEW}" >> ${GITHUB_ENV} | |
- name: Set production deployment url variable | |
if: ${{ contains(github.ref, 'master') }} | |
run: echo "DEPLOYMENT_URL=https://${DEMO_BASE_URL_PRODUCTION}" >> ${GITHUB_ENV} | |
- id: output_step | |
run: | | |
echo "github_ref_slug=${GITHUB_REF_SLUG_URL}" >> $GITHUB_OUTPUT | |
echo "deployment_url=${DEPLOYMENT_URL}" >> $GITHUB_OUTPUT | |
deploy-demo-preview: | |
runs-on: ubuntu-latest | |
needs: [deploy-demo-setup] | |
if: ${{ github.event_name == 'push' && !contains(github.ref, 'master') && !contains(github.ref, 'tags') }} | |
environment: | |
name: preview/${{ needs.deploy-demo-setup.outputs.github_ref_slug }} | |
url: ${{ needs.deploy-demo-setup.outputs.deployment_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Inject slug/short variables | |
uses: rlespinasse/github-slug-action@v5 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Cache Python modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade poetry | |
poetry install | |
- name: Deploy to Vercel | |
run: |- | |
VERCEL_ALIAS=${GITHUB_REF_SLUG_URL}-${DEMO_BASE_URL_PREVIEW} | |
VERCEL_URL=$(poetry run datasette publish vercel demo/jobs.db \ | |
--metadata demo/metadata.yml \ | |
--template-dir demo/templates \ | |
--install=datasette-cluster-map \ | |
--install=datasette-vega \ | |
--install=datasette-block-robots \ | |
--install=datasette-sqlite-http \ | |
--install=https://github.com/rclement/datasette-dashboards/archive/${GITHUB_SHA}.zip \ | |
--project=${{ secrets.VERCEL_PROJECT }} \ | |
--token=${{ secrets.VERCEL_TOKEN }} \ | |
--no-prod) | |
vercel alias --token ${{ secrets.VERCEL_TOKEN }} set ${VERCEL_URL} ${VERCEL_ALIAS} | |
deploy-demo-production: | |
runs-on: ubuntu-latest | |
needs: [deploy-demo-setup] | |
if: contains(github.ref, 'master') | |
environment: | |
name: demo | |
url: ${{ needs.deploy-demo-setup.outputs.deployment_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Cache Python modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade poetry | |
poetry install | |
- name: Deploy to Vercel | |
run: |- | |
poetry run datasette publish vercel demo/jobs.db \ | |
--metadata demo/metadata.yml \ | |
--template-dir demo/templates \ | |
--install=datasette-cluster-map \ | |
--install=datasette-vega \ | |
--install=datasette-block-robots \ | |
--install=datasette-sqlite-http \ | |
--install=https://github.com/rclement/datasette-dashboards/archive/${GITHUB_SHA}.zip \ | |
--project=${{ secrets.VERCEL_PROJECT }} \ | |
--token=${{ secrets.VERCEL_TOKEN }} | |
publish-package-test: | |
runs-on: ubuntu-latest | |
needs: [test] | |
if: contains(github.ref, 'master') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- uses: actions/cache@v4 | |
name: Configure pip caching | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/pyproject.toml') }} | |
restore-keys: | | |
${{ runner.os }}-publish-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade poetry | |
poetry install | |
- name: Build Python package | |
run: poetry build | |
- name: Publish Python package on PyPI | |
env: | |
POETRY_REPOSITORIES_TESTPYPI_URL: https://test.pypi.org/legacy/ | |
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.PYPI_TOKEN_TEST }} | |
POETRY_HTTP_BASIC_TESTPYPI_USERNAME: __token__ | |
POETRY_HTTP_BASIC_TESTPYPI_PASSWORD: ${{ secrets.PYPI_TOKEN_TEST }} | |
run: poetry publish -r testpypi --skip-existing | |
publish-package: | |
runs-on: ubuntu-latest | |
needs: [test] | |
if: contains(github.ref, 'tags') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- uses: actions/cache@v4 | |
name: Configure pip caching | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/pyproject.toml') }} | |
restore-keys: | | |
${{ runner.os }}-publish-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade poetry | |
poetry install | |
- name: Build Python package | |
run: poetry build | |
- name: Publish Python package on PyPI | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | |
POETRY_HTTP_BASIC_PYPI_USERNAME: __token__ | |
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: poetry publish | |
take-shots: | |
runs-on: ubuntu-latest | |
needs: [deploy-demo-production] | |
if: contains(github.ref, 'master') | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
# with: | |
# token: ${{ secrets.GH_PERSONAL_TOKEN }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- uses: actions/cache@v4 | |
name: Configure pip caching | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip | |
- name: Cache Playwright browsers | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/ms-playwright/ | |
key: ${{ runner.os }}-playwright | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade shot-scraper | |
shot-scraper install | |
- name: Demo dashboard screenshot | |
run: | | |
shot-scraper \ | |
"https://${DEMO_BASE_URL_PRODUCTION}/-/dashboards/job-offers-stats?date_start=2021-01-01&date_end=2021-05-01&source=®ion=" \ | |
--output demo/datasette-dashboards-demo.png \ | |
--wait 1000 \ | |
--width 1440 \ | |
--retina | |
- name: Upload screenshot artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshot | |
path: demo/datasette-dashboards-demo.png | |
# - name: Commit and push changes | |
# run: | | |
# git config user.name "Automated" | |
# git config user.email "actions@users.noreply.github.com" | |
# git add -A | |
# timestamp=$(date -u) | |
# git commit -m "Latest data: ${timestamp}" || exit 0 | |
# git push |