Skip to content

Commit

Permalink
Merge branch 'main' into alokshin/CCIE-1977-support-pod-disruption-bu…
Browse files Browse the repository at this point in the history
…dgets
  • Loading branch information
alexlokshin-czi committed Oct 23, 2023
2 parents 3e0f9f7 + fe3273a commit 9067dbd
Show file tree
Hide file tree
Showing 112 changed files with 7,780 additions and 976 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/api-update-ent-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
name: api-ent-schema
jobs:
api_changes:
runs-on: [ARM64, self-hosted, Linux]
permissions:
pull-requests: read
outputs:
run_api_ci: ${{ steps.filter.outputs.dependencies }}
steps:
- name: Check for changed files
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dependencies:
- '.github/**'
- 'api/**'
- 'shared/**'
update-api-ent-schema:
needs: api_changes
if: ${{ needs.api_changes.outputs.run_api_ci == 'true' }}
runs-on: [ARM64, self-hosted, Linux]
steps:
- name: Generate token
id: generate_token
uses: chanzuckerberg/[email protected]
with:
app_id: ${{ secrets.CZI_GITHUB_HELPER_APP_ID }}
private_key: ${{ secrets.CZI_GITHUB_HELPER_PK }}
- uses: actions/checkout@v3
with:
token: ${{ steps.generate_token.outputs.token }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-go@v4
with:
go-version-file: api/go.mod
cache: true
- run: make update-ent-schema
working-directory: api
- uses: EndBug/add-and-commit@v9
with:
add: -A
message: ci - update ent schema
102 changes: 102 additions & 0 deletions .github/workflows/charts-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Release Charts

on:
release:
types: [published]

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

jobs:
check-chart-released:
runs-on: [ARM64, self-hosted, Linux]
steps:
- name: Check Release
id: chart_released
uses: actions/github-script@v5
with:
script: |
core.setOutput("released", context.ref.includes('refs/tags/happy-stack-helm'))
core.setOutput("tag", context.ref.split("/").pop())
outputs:
chart_released: ${{ steps.chart_released.outputs.released }}
tag: ${{ steps.chart_released.outputs.tag }}
release:
if: ${{ needs.check-chart-released.outputs.chart_released == 'true' }}
needs:
- check-chart-released
# NOTE: needs to be X64 because of helm-releaser
runs-on: [ARM64, self-hosted, Linux]
steps:
- name: Generate token
id: generate_token
uses: chanzuckerberg/[email protected]
with:
app_id: ${{ secrets.CZI_RELEASE_PLEASE_APP_ID }}
private_key: ${{ secrets.CZI_RELEASE_PLEASE_PK }}
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
path: main
token: ${{ steps.generate_token.outputs.token }}
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
path: chart-repo
repository: chanzuckerberg/happy-helm-charts
token: ${{ steps.generate_token.outputs.token }}
- name: Publish charts
run: |
set -ue
set -o pipefail
# install helm
RELEASE_URL=https://get.helm.sh/helm-v3.13.1-linux-arm64.tar.gz
DIR_NAME=helm
OUT_DIR="/tmp/${DIR_NAME}"
mkdir -p ${OUT_DIR}
OUT_FILE="${OUT_DIR}/helm.tar.gz"
curl -sSL ${RELEASE_URL} -o ${OUT_FILE}
tar -zxf ${OUT_FILE} -C ${OUT_DIR}
HELM_CMD=$(find ${OUT_DIR} -type f -name "helm")
chmod +x ${HELM_CMD}
# install ghcli
GHCLI_URL="https://github.com/cli/cli/releases/download/v2.30.0/gh_2.30.0_linux_arm64.tar.gz"
GHCLI_DIR_NAME=ghcli
GHCLI_TOOL_PATH="/tmp/${GHCLI_DIR_NAME}"
mkdir -p ${GHCLI_TOOL_PATH}
GHCLI_OUT_FILE="${GHCLI_TOOL_PATH}/ghcli.tar.gz"
curl -sSL $GHCLI_URL -L -o ${GHCLI_OUT_FILE}
tar -zxf ${GHCLI_OUT_FILE} -C ${GHCLI_TOOL_PATH} --strip-components 1
GHCLI_CMD=$(find ${GHCLI_TOOL_PATH} -type f -name "gh")
${GHCLI_CMD} auth login --with-token < <(echo $GH_CRED)
${GHCLI_CMD} auth status
# packages will be uploaded to their release
PACKAGE_DIR="/tmp"
# the index.yaml file will be hosted by the happy github pages site
INDEX_DIR="${GITHUB_WORKSPACE}/chart-repo"
# the location of the chart package
CHARTS_DIR="${GITHUB_WORKSPACE}/main/helm-charts/charts/stack"
# location of release to download the chart from
CHART_DOWNLOAD_URL="https://github.com/chanzuckerberg/${{ github.repository }}/releases/download/${{ needs.check-chart-released.outputs.tag }}"
git config --global user.email "[email protected]"
git config --global user.name "CZI Happy Helm Publisher Bot"
cd main
${HELM_CMD} package ${CHARTS_DIR} -d ${PACKAGE_DIR}
${GHCLI_CMD} release upload ${{ needs.check-chart-released.outputs.tag }} ${PACKAGE_DIR}/*.tgz --clobber
${HELM_CMD} repo index ${PACKAGE_DIR} --url ${CHART_DOWNLOAD_URL} --merge ${INDEX_DIR}/index.yaml
cd ../chart-repo
mv ${PACKAGE_DIR}/index.yaml .${INDEX_DIR}/index.yaml
git add -A
git commit -m "chore: publish charts from ${{ github.repository }} ${{ needs.check-chart-released.outputs.tag }}"
git push
env:
GH_CRED: ${{ secrets.GITHUB_TOKEN }}
19 changes: 10 additions & 9 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"cli": "0.110.1",
"api": "0.110.1",
"shared": "0.110.1",
"terraform/provider": "0.110.1",
"cli": "0.113.1",
"api": "0.113.1",
"shared": "0.113.1",
"terraform/provider": "0.113.1",
"terraform/modules/happy-dns-ecs": "1.5.0",
"terraform/modules/happy-env-ecs": "3.3.0",
"terraform/modules/happy-env-eks": "4.12.2",
"terraform/modules/happy-github-ci-role": "1.4.2",
"terraform/modules/happy-github-ci-role": "1.5.0",
"terraform/modules/happy-route53": "1.3.0",
"terraform/modules/happy-service-ecs": "2.1.0",
"terraform/modules/happy-service-eks": "3.17.0",
"terraform/modules/happy-service-eks": "3.17.2",
"terraform/modules/happy-stack-ecs": "2.1.0",
"terraform/modules/happy-stack-eks": "4.19.0",
"terraform/modules/happy-stack-eks": "4.20.0",
"terraform/modules/happy-tfe-okta-app": "3.0.0",
"terraform/modules/happy-tfe-user": "1.3.0",
"terraform/modules/happy-ingress-eks": "2.9.0",
"hvm": "0.110.1",
"hvm": "0.113.1",
"hapi-proto": "0.1.0",
"terraform/modules/happy-cloudfront": "1.0.0"
"terraform/modules/happy-cloudfront": "1.0.0",
"helm-charts/charts/stack": "0.1.0"
}
2 changes: 1 addition & 1 deletion Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WORKDIR /code/api

ARG RELEASE_VERSION
ARG GITHUB_SHA
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${PLATFORM} go build -o /code/api/dist/happy-api -ldflags "-w -s -X github.com/chanzuckerberg/happy/shared/util.ReleaseGitSha=${GITHUB_SHA} -X github.com/chanzuckerberg/happy/shared/util.ReleaseVersion=${RELEASE_VERSION}"
RUN --mount=type=cache,mode=0755,target=/go/pkg/mod GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${PLATFORM} go build -o /code/api/dist/happy-api -ldflags "-w -s -X github.com/chanzuckerberg/happy/shared/util.ReleaseGitSha=${GITHUB_SHA} -X github.com/chanzuckerberg/happy/shared/util.ReleaseVersion=${RELEASE_VERSION}"

# --------------------------------------------------------------------------------------------------

Expand Down
4 changes: 3 additions & 1 deletion api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
gorm.db
hapi.db
happy-api
api
/api

.vscode/
node_modules/
35 changes: 35 additions & 0 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Changelog

## [0.113.1](https://github.com/chanzuckerberg/happy/compare/api-v0.113.0...api-v0.113.1) (2023-10-18)


### Miscellaneous Chores

* **api:** Synchronize happy platform versions

## [0.113.0](https://github.com/chanzuckerberg/happy/compare/api-v0.112.1...api-v0.113.0) (2023-10-17)


### Features

* start using the appconfig 'source' column ([#2597](https://github.com/chanzuckerberg/happy/issues/2597)) ([2c63967](https://github.com/chanzuckerberg/happy/commit/2c639678867e1514105e00d06eb2c5ea007861e4))

## [0.112.1](https://github.com/chanzuckerberg/happy/compare/api-v0.112.0...api-v0.112.1) (2023-10-17)


### Bug Fixes

* revert aws config dep to allow creation of shared config ([#2606](https://github.com/chanzuckerberg/happy/issues/2606)) ([470c0a1](https://github.com/chanzuckerberg/happy/commit/470c0a12d1a4763c011bd89f4686414fbfc781dd))

## [0.112.0](https://github.com/chanzuckerberg/happy/compare/api-v0.111.0...api-v0.112.0) (2023-10-16)


### Features

* add 'source' column to app_configs table ([#2596](https://github.com/chanzuckerberg/happy/issues/2596)) ([76bc701](https://github.com/chanzuckerberg/happy/commit/76bc701e921617290394ed27a87de107eb362256))

## [0.111.0](https://github.com/chanzuckerberg/happy/compare/api-v0.110.1...api-v0.111.0) (2023-10-13)


### Features

* replace Gorm with Ent ORM ([#2530](https://github.com/chanzuckerberg/happy/issues/2530)) ([fa87b1a](https://github.com/chanzuckerberg/happy/commit/fa87b1a0bbd2c6b41ac4e9f013c8c60ff5409913))

## [0.110.1](https://github.com/chanzuckerberg/happy/compare/api-v0.110.0...api-v0.110.1) (2023-10-05)


Expand Down
11 changes: 9 additions & 2 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ clean-dist: ## Removing dist directory
dev: ## Run app in development mode with current working directory as config
@CONFIG_YAML_DIRECTORY=./ TZ=utc APP_ENV=development aws-oidc exec --profile czi-si-readonly -- chamber exec happy-ldev-hapi -- go run main.go

dev-docker:
aws-oidc exec --profile czi-si-readonly -- chamber exec happy-ldev-hapi -- docker-compose --profile hapi up --build

dev-db-shell:
docker exec -it api-hapi-1 /tools/db-shell.sh

test: ## Run tests for API
@CONFIG_YAML_DIRECTORY=../.. TZ=utc APP_ENV=test go test ./... -run ^$(name)

Expand All @@ -36,5 +42,6 @@ update-docs: ## Update swagger docs
docker: ## Build docker image using scratch and Dockerfile.api in root project directory
pushd ../ && docker build -t happy-api:dev -f Dockerfile.api .

docker-dev:
aws-oidc exec --profile czi-si-readonly -- chamber exec happy-ldev-hapi -- docker-compose --profile hapi up --build
update-ent-schema:
## This will update the ent schema and regenerate the ent code. We need to run `go mod tidy` after the fact to update the go.mod file
go generate ./pkg/ent && go mod tidy
4 changes: 2 additions & 2 deletions api/app-config.development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ auth:
# - client_id: "k8s-test-app-rdev-happy-service-account"
# issuer_url: "https://czi-prod.okta.com/oauth2/aus8a6q70ndVGTrhp5d7"
database:
driver: sqlite
data_source_name: gorm.db
driver: sqlite3
data_source_name: hapi.db?_fk=1
log_level: info
2 changes: 2 additions & 0 deletions api/app-config.docker-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ auth:
enable: false
database:
log_level: info
driver: postgres
data_source_name: host={{.HAPPY_DATABASE_HOST}} user={{.HAPPY_DATABASE_USER}} password={{.HAPPY_DATABASE_PASSWORD}} port={{.HAPPY_DATABASE_PORT}} dbname={{.HAPPY_DATABASE_NAME}} sslmode=disable
2 changes: 1 addition & 1 deletion api/app-config.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ auth:
api:
log_level: silent
database:
driver: sqlite
driver: sqlite3
data_source_name: ":memory:"
log_level: silent
8 changes: 5 additions & 3 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ services:
profiles:
- hapi
restart: always
command: postgres -c 'max_connections=500'
ports:
- 5432:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=REPLACEME
- POSTGRES_DB=postgres
- PGPASSWORD=REPLACEME
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d postgres" ]
interval: 10s
timeout: 5s
retries: 5
interval: 3s
timeout: 3s
retries: 10
Loading

0 comments on commit 9067dbd

Please sign in to comment.