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: switch from cicleci to github actions #888

Merged
merged 33 commits into from
Apr 26, 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
78 changes: 78 additions & 0 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: bot

on:
pull_request:

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

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@c449d86cf33a2a6c7a4193264cc2578e2c3266d4 # pin@v4
with:
paths: '["bot/**", ".github/workflows/**"]'

test:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
services:
redis:
image: redis:5
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry==1.1.13
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v4
with:
python-version-file: "./bot/.python-version"
cache: poetry
cache-dependency-path: "./bot/poetry.lock"
- name: Install dependencies
working-directory: "./bot"
run: poetry install
- name: Run tests
working-directory: "bot"
run: ./s/test
- name: upload code coverage
working-directory: bot
run: ./s/upload-code-cov
lint:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry==1.1.13
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v4
with:
python-version-file: "./bot/.python-version"
cache: poetry
cache-dependency-path: "./bot/poetry.lock"
- name: Install dependencies
working-directory: "./bot"
run: poetry install
- name: Run lints
working-directory: "bot"
run: ./s/lint
73 changes: 73 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: docs

on:
pull_request:

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

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@c449d86cf33a2a6c7a4193264cc2578e2c3266d4 # pin@v4
with:
paths: '["docs/**", ".github/workflows/**"]'
typecheck:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: "docs/package.json"
cache-dependency-path: "docs/yarn.lock"
cache: "yarn"
- name: Install dependencies
working-directory: "docs"
run: yarn install --frozen-lockfile
- name: run typechecker
working-directory: "docs"
run: ./s/typecheck

fmt:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: "docs/package.json"
cache-dependency-path: "docs/yarn.lock"
cache: "yarn"
- name: Install dependencies
working-directory: "docs"
run: yarn install --frozen-lockfile
- name: Run tests
working-directory: "docs"
run: ./s/fmt-ci

verify_build:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: "docs/package.json"
cache-dependency-path: "docs/yarn.lock"
cache: "yarn"
- name: Install dependencies
working-directory: "docs"
run: yarn install --frozen-lockfile
- name: Run tests
working-directory: "docs"
run: ./s/build
107 changes: 107 additions & 0 deletions .github/workflows/infrastructure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: infrastructure

on:
pull_request:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
commit_sha:
description: "SHA to deploy"
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: false

# TODO: Skip if no changes in directory
jobs:
lint_shell:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Install dependencies
run: |
sudo apt install shellcheck
- name: Run shellcheck
run: ./s/shellcheck

build_bot_container:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:bot"
push: true
file: "Dockerfile"
tags: cdignam/kodiak:${{ github.event.pull_request.head.sha || github.sha }}
cache-from: type=gha,scope=kodiak
cache-to: type=gha,scope=kodiak,mode=max

build_api_container:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:web_api"
push: true
file: "Dockerfile"
tags: cdignam/kodiak-web-api:${{ github.event.pull_request.head.sha || github.sha }}
cache-from: type=gha,scope=kodiak-web-api
cache-to: type=gha,scope=kodiak-web-api,mode=max
build-args: |
GIT_SHA=${{ github.event.pull_request.head.sha || github.sha }}

build_web_ui_container:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:web_ui"
push: true
file: "Dockerfile"
tags: cdignam/kodiak-web-ui:${{ github.event.pull_request.head.sha || github.sha }}
cache-from: type=gha,scope=kodiak-web-ui
cache-to: type=gha,scope=kodiak-web-ui,mode=max
build-args: |
GIT_SHA=${{ github.event.pull_request.head.sha || github.sha }}
138 changes: 138 additions & 0 deletions .github/workflows/web_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: web_api

on:
pull_request:

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

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@c449d86cf33a2a6c7a4193264cc2578e2c3266d4 # pin@v4
with:
paths: '["web_api/**", ".github/workflows/**"]'

test:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:5
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry==1.7.1
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v4
with:
python-version-file: "./web_api/.python-version"
cache: poetry
cache-dependency-path: "./web_api/poetry.lock"
- name: Install dependencies
working-directory: "./web_api"
run: poetry install
- name: Set up environment variables
run: echo "DATABASE_URL=postgres://postgres:[email protected]:5432/postgres" >> $GITHUB_ENV
- name: Run tests
working-directory: "web_api"
run: ./s/test
- name: upload code coverage
working-directory: web_api
run: ./s/upload-code-cov
lint:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry==1.7.1
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v4
with:
python-version-file: "./web_api/.python-version"
cache: poetry
cache-dependency-path: "./web_api/poetry.lock"
- name: Install dependencies
working-directory: "./web_api"
run: poetry install
- name: Run lints
working-directory: "web_api"
run: ./s/lint

squawk:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: web_api_test
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 0
- name: Install poetry
run: |
pipx install poetry==1.7.1
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v4
with:
python-version-file: "./web_api/.python-version"
cache: poetry
cache-dependency-path: "./web_api/poetry.lock"
- name: Install dependencies
working-directory: "./web_api"
run: poetry install
- name: Run squawk
working-directory: "./web_api"
run: |
python ./s/squawk.py
- uses: sbdchd/squawk-action@v1
with:
pattern: "web_api/migrations/*.sql"
version: "latest"
Loading
Loading