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

migrate CI to use python invoke #2736

Merged
merged 56 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f4c9c40
create ci poetry environment with some possible tools
atvaccaro Jun 20, 2023
19d50a1
add gitpython and decouple
atvaccaro Jun 20, 2023
c36cbf1
start on diffing in CI
atvaccaro Jun 20, 2023
e5fbb67
fix diff working dir
atvaccaro Jun 21, 2023
168688d
run diff when commits are pushed on PR
atvaccaro Jun 21, 2023
ec6b2da
install deps
atvaccaro Jun 21, 2023
9109b47
add missing token
atvaccaro Jun 21, 2023
4b52ee4
try specifying token
atvaccaro Jun 21, 2023
bf97e1e
try not persisting credentials in candidate action
atvaccaro Jun 21, 2023
ea0b444
try specifying token
atvaccaro Jun 21, 2023
8dd127d
specify dotenv, remove unnecessary deps
atvaccaro Jun 21, 2023
ed7b28c
use new bot token for actions
atvaccaro Jun 21, 2023
6bcde57
start on pydantic with invoke, and change test consumer to test
atvaccaro Jun 21, 2023
e2e658f
switch back, try to fix body-file comment
atvaccaro Jun 21, 2023
8faff75
not in env?
atvaccaro Jun 21, 2023
2964cf5
just set work dir
atvaccaro Jun 21, 2023
4d190bd
one more
atvaccaro Jun 21, 2023
e9254f5
always write to kdiff file
atvaccaro Jun 21, 2023
390b460
logging
atvaccaro Jun 21, 2023
5f2e922
change github ref handling
atvaccaro Jun 21, 2023
b3c506b
markdown formatting and handle empty diffs
atvaccaro Jun 21, 2023
0fbc143
fix getting diff comment to edit
atvaccaro Jun 21, 2023
4163abf
start representing channels as yaml
atvaccaro Jun 22, 2023
da6cca6
remove release prefix
atvaccaro Jun 22, 2023
13b0275
move channels into invoke.yaml
atvaccaro Jun 22, 2023
1901e82
helm diff in invoke
atvaccaro Jun 22, 2023
b1a0443
handle empty helm values, put prod releases in yaml
atvaccaro Jun 22, 2023
0960748
call helm diff and cat together with kustomize diff
atvaccaro Jun 22, 2023
4eed516
fix printing, and use release candidate in metabase-test to test
atvaccaro Jun 22, 2023
b781257
implement helm releases, remove legacy test envs
atvaccaro Jun 22, 2023
abce058
switch service release to invoke
atvaccaro Jun 22, 2023
7ca1242
fix invoke call
atvaccaro Jun 22, 2023
64e7308
delete legacy prod ci
atvaccaro Jun 22, 2023
9a44d93
remove outdated comment
atvaccaro Jun 22, 2023
3b95b74
one more
atvaccaro Jun 22, 2023
5733cf6
wip on updating infra/ci docs
atvaccaro Jun 23, 2023
7b71f1f
start streamlining invoke tasks
atvaccaro Jun 23, 2023
25e62f0
remove unused config var
atvaccaro Jun 23, 2023
ebd07ce
help text
atvaccaro Jun 23, 2023
2edb932
add mypy, make pass
atvaccaro Jun 23, 2023
063367d
clean up gitops docs
atvaccaro Jun 23, 2023
1a65be6
wip on secrets, and just use yaml lists where appropriate
atvaccaro Jun 23, 2023
23d9485
couple cleanups from review
atvaccaro Jun 23, 2023
a253814
finish handling secrets, do in test
atvaccaro Jun 23, 2023
14d2fb3
split channels into separate config files
atvaccaro Jun 23, 2023
7b8027c
add pyyaml types
atvaccaro Jun 23, 2023
e07374c
define prod secrets
atvaccaro Jun 23, 2023
a6e93da
make docs build
atvaccaro Jun 23, 2023
bc7c44c
only run 1 test consumer to test diff/deploy
atvaccaro Jun 23, 2023
6936bd8
add quotes
atvaccaro Jun 23, 2023
020fbb7
add a todo
atvaccaro Jun 23, 2023
0de07eb
another todo
atvaccaro Jun 23, 2023
c9e2019
add todo
atvaccaro Jun 26, 2023
525a139
ensure secrets/exceptions are not echoed
atvaccaro Jun 26, 2023
5ec2ae3
fix secret handling
atvaccaro Jun 26, 2023
1ab4613
address PR comments
atvaccaro Jun 26, 2023
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
3 changes: 2 additions & 1 deletion .github/workflows/service-release-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:


env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }}
BIO_RELEASE: 1.6.372


Expand All @@ -28,6 +28,7 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.GH_ACTIONS_TOKEN }}

- name: 'Build release candidate branch'
run: |
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/service-release-channel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,31 @@ jobs:
GKE_REGION: us-west1
USE_GKE_GCLOUD_AUTH_PLUGIN: True
steps:

# Setup
- name: Check out repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true

- name: install auth plugin
run: gcloud components install gke-gcloud-auth-plugin

- uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: ${{ env.GKE_NAME }}
location: ${{ env.GKE_REGION }}
- run: curl -sSL https://install.python-poetry.org | python -

- id: service-release
name: Run ci/workflows/service-release.sh
# Release to channel
- id: poetry-invoke
name: Run poetry invoke
shell: bash
working-directory: ci
run: |
# GITHUB_JOB is not populated until the job is running
git config user.name "Github Action $GITHUB_JOB"
git config user.email "$(whoami)@$(uname -n)"
export RELEASE_CHANNEL=${GITHUB_REF#refs/heads/releases/}
printf 'WORKFLOW: service-release; RELEASE_CHANNEL=%s\n' "$RELEASE_CHANNEL"
set -- "$GITHUB_WORKSPACE/ci/vars/project.env"
source "$GITHUB_WORKSPACE/ci/workflows/service-release.sh"
printf 'WORKFLOW: service-release-channel; RELEASE_CHANNEL=%s\n' "$RELEASE_CHANNEL"
poetry install
poetry run invoke secrets -f "./channels/$RELEASE_CHANNEL.yaml"
poetry run invoke release -f "./channels/$RELEASE_CHANNEL.yaml"
62 changes: 62 additions & 0 deletions .github/workflows/service-release-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Show diff for release channel

on:
pull_request:
branches:
- 'releases/*'
types:
- opened
- synchronize
- reopened

env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }}

jobs:
release:
runs-on: ubuntu-latest
env:
CLOUDSDK_CORE_PROJECT: cal-itp-data-infra
GKE_NAME: data-infra-apps
GKE_REGION: us-west1
USE_GKE_GCLOUD_AUTH_PLUGIN: True
steps:
# Setup
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- run: gcloud components install gke-gcloud-auth-plugin
- uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: ${{ env.GKE_NAME }}
location: ${{ env.GKE_REGION }}
- run: curl -sSL https://install.python-poetry.org | python -

# Diff and write back to PR
- id: diff
name: Run poetry invoke
shell: bash
working-directory: ci
run: |
export RELEASE_CHANNEL=${GITHUB_BASE_REF#releases/}
printf 'WORKFLOW: service-release-diff; RELEASE_CHANNEL=%s\n' "$RELEASE_CHANNEL"
poetry install
poetry run invoke diff -f "./channels/$RELEASE_CHANNEL.yaml" --outfile=diff.txt

- uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
direction: last
- uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body-file: "ci/diff.txt"
edit-mode: replace
91 changes: 91 additions & 0 deletions ci/channels/prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
calitp:
channel: prod
releases:
- name: airflow-jobs
driver: kustomize
kustomize_dir: kubernetes/apps/manifests/airflow-jobs
secrets:
- airflow-jobs_jobs-data
- name: grafana
driver: helm
namespace: monitoring-grafana
helm_name: grafana
helm_chart: kubernetes/apps/charts/grafana
helm_values:
- kubernetes/apps/values/grafana.yaml:kubernetes/apps/values/grafana-prod.yaml
secrets:
- monitoring-grafana__grafana-initial-admin
- name: jupyterhub
driver: helm
namespace: jupyterhub
helm_name: jupyterhub
helm_chart: kubernetes/apps/charts/jupyterhub
secrets:
- jupyterhub_jupyterhub-gcloud-service-key
- jupyterhub_jupyterhub-github-config
- name: loki
driver: helm
namespace: monitoring-loki
helm_name: loki
helm_chart: kubernetes/apps/charts/loki
- name: metabase
driver: helm
namespace: metabase
helm_name: metabase
helm_chart: kubernetes/apps/charts/metabase
helm_values:
- kubernetes/apps/values/metabase.yaml
secrets:
- metabase_service_account_key
- name: postgresql-backup-grafana
driver: helm
namespace: grafana
helm_name: postgresql-backup
helm_chart: kubernetes/apps/charts/postgresql-backup
helm_values:
- kubernetes/apps/values/postgresql-backup-grafana.yaml
secrets:
- monitoring-grafana_database-backup
- monitoring-grafana_grafana-postgresql
- name: postgresql-backup-metabase
driver: helm
namespace: metabase
helm_name: postgresql-backup
helm_chart: kubernetes/apps/charts/postgresql-backup
helm_values:
- kubernetes/apps/values/postgresql-backup-metabase.yaml:kubernetes/apps/values/postgresql-backup-metabase-prod.yaml
secrets:
- metabase_database-backup
- metabase_gcs-upload-svcacct
- name: postgresql-backup-sentry
driver: helm
namespace: sentry
helm_name: postgresql-backup
helm_chart: kubernetes/apps/charts/postgresql-backup
helm_values:
- kubernetes/apps/values/postgresql-backup-sentry.yaml
secrets:
- sentry_database-backup
- name: prometheus
driver: helm
namespace: monitoring-prometheus
helm_name: prometheus
helm_chart: kubernetes/apps/charts/prometheus
helm_values:
- kubernetes/apps/values/prometheus.yaml
- name: promtail
driver: helm
namespace: monitoring-loki
helm_name: promtail
helm_chart: kubernetes/apps/charts/promtail
helm_values:
- kubernetes/apps/values/promtail.yaml
- name: sftp-ingest-elavon
driver: kustomize
kustomize_dir: kubernetes/apps/overlays/prod-sftp-ingest-elavon
# TODO: sftp secrets
# TODO: Sentry
# - name: sentry
# secrets:
# - sentry_sentry-secret
# - sentry_sentry-sentry-postgresql
26 changes: 26 additions & 0 deletions ci/channels/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
calitp:
channel: test
releases:
- name: archiver
driver: kustomize
kustomize_dir: kubernetes/apps/overlays/gtfs-rt-archiver-v3-test
secrets:
- gtfs-rt-v3-test_gtfs-feed-secrets
- name: metabase
driver: helm
namespace: metabase-test
helm_name: metabase-test
helm_chart: kubernetes/apps/charts/metabase
helm_values:
- kubernetes/apps/values/metabase-test.yaml
- name: postgresql-backup-metabase
driver: helm
namespace: metabase-test
helm_name: postgresql-backup
helm_chart: kubernetes/apps/charts/postgresql-backup
helm_values:
- kubernetes/apps/values/postgresql-backup-metabase.yaml
- kubernetes/apps/values/postgresql-backup-metabase-test.yaml
secrets:
- metabase-test_database-backup
- metabase-test_gcs-upload-svcacct
5 changes: 5 additions & 0 deletions ci/invoke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
run:
echo: true
echo_format: "Executing: {command}" # without this, the echoed text is white which does not show on light themes
calitp:
git_repo: .
Loading
Loading