Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Configure build and deployment of site #48

Merged
merged 5 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# GitHub Actions for Dewy

We currently have 3 workflows:

1. `ci.yml` defines the CI process for the core service and clients.
2. `lint-pr.yml` defines linting of the PR itself (comments, etc.).
3. `site.yml` defines the build and deployment process for the site.

## Future Improvements

1. Release drafting / publishing.
2. Assign labels to PRs based on directories touched (eg., `docs`, `service`, etc.) and
conventional commit (`fix`, `feature`, etc.).
3. Require conditional checks https://github.com/marketplace/actions/require-conditional-status-checks
110 changes: 55 additions & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
name: CI

on:
push:
branches:
- master
pull_request:
push:
branches:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
python_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v4
# see details (matrix, python-version, python-version-file, etc.)
# https://github.com/actions/setup-python
with:
python-version: '3.11'
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install the project dependencies
run: poetry install --with=dev
- name: pytest
run: poetry run pytest -v
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: check openapi client up to date
run: |
poetry run poe extract-openapi
poetry run poe update-client
# Record intent to add any new files in client
git add -N dewy-client
# Diff, and report any changes (including any new files in dewy-client)
git diff --exit-code
python_test:
runs-on: ubuntu-latest
kerinin marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v4
# see details (matrix, python-version, python-version-file, etc.)
# https://github.com/actions/setup-python
with:
python-version: '3.11'
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install the project dependencies
run: poetry install --with=dev
- name: pytest
run: poetry run pytest -v
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: check openapi client up to date
run: |
poetry run poe extract-openapi
poetry run poe update-client
# Record intent to add any new files in client
git add -N dewy-client
# Diff, and report any changes (including any new files in dewy-client)
git diff --exit-code

python_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ruff Lint
uses: chartboost/ruff-action@v1
python_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ruff Lint
uses: chartboost/ruff-action@v1

python_format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ruff Format (Check)
uses: chartboost/ruff-action@v1
with:
args: format --check
python_format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ruff Format (Check)
uses: chartboost/ruff-action@v1
with:
args: format --check
56 changes: 56 additions & 0 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Site

on:
push:
branches:
- main
paths:
- 'docs/**'
- '.github/workflows/site.yml'
pull_request:
kerinin marked this conversation as resolved.
Show resolved Hide resolved
paths:
- 'docs/**'
- '.github/workflows/site.yml'

permissions:
contents: write

jobs:
deploy:
name: Build and (maybe) Deploy Site
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
cache-dependency-path: docs/package-lock.json

- name: Install dependencies
run: yarn install --frozen-lockfile
working-directory: docs
- name: Build website
run: yarn build
working-directory: docs

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
# Only run on push to main.
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
publish_dir: ./docs/build
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
Loading