Skip to content

Commit

Permalink
ci: switch from cicleci to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbdchd committed Apr 25, 2024
1 parent 4e8e180 commit f397ba6
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 1 deletion.
69 changes: 69 additions & 0 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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
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: "./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.7.1
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
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:
branches:
- main
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 }}
125 changes: 125 additions & 0 deletions .github/workflows/web_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
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
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
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 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@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 tests
run: |
curl -sL https://deb.nodesource.com/setup_14.x | bash -
sudo apt-get install -y nodejs
- name: Set up environment variables
run: echo "DATABASE_URL=postgres://postgres:[email protected]:5432/web_api_test" >> $GITHUB_ENV
- name: run squawk
working-directory: "./web_api"
run: ./s/squawk.py
55 changes: 55 additions & 0 deletions .github/workflows/web_ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: web_ui

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_ui/**", ".github/workflows/**"]'
test:
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: "web_ui/package.json"
cache-dependency-path: "web_ui/yarn.lock"
cache: "yarn"
- name: Install dependencies
working-directory: "web_ui"
run: yarn install --frozen-lockfile
- name: Run tests
working-directory: "web_ui"
run: ./s/test

list:
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: "web_ui/package.json"
cache-dependency-path: "web_ui/yarn.lock"
cache: "yarn"
- name: Install dependencies
working-directory: "web_ui"
run: yarn install --frozen-lockfile
- name: Run tests
working-directory: "web_ui"
run: ./s/list
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ profile_default/
ipython_config.py

# pyenv
.python-version
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down
1 change: 1 addition & 0 deletions web_api/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7.13

0 comments on commit f397ba6

Please sign in to comment.