From b3f1ca3085e4a13f277a31fe7ffb1e945a810be4 Mon Sep 17 00:00:00 2001 From: max funk Date: Fri, 27 Dec 2024 11:28:09 -0700 Subject: [PATCH 1/4] add cue file --- cue/README.md | 11 +++ cue/project_conf.cue | 165 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 cue/README.md create mode 100644 cue/project_conf.cue diff --git a/cue/README.md b/cue/README.md new file mode 100644 index 00000000..7333a128 --- /dev/null +++ b/cue/README.md @@ -0,0 +1,11 @@ +

+ systemaccounting +

+ +[cuelang](https://cuelang.org/docs/) uses: + +test types in large `project.yaml` file. example command: + +```sh +cue vet ./cue/project_conf.cue project.yaml +``` \ No newline at end of file diff --git a/cue/project_conf.cue b/cue/project_conf.cue new file mode 100644 index 00000000..83159d3d --- /dev/null +++ b/cue/project_conf.cue @@ -0,0 +1,165 @@ +package project_conf + +#AppType: *"app" | "lib" | "tool" +#Runtime: *"rust1.x" | "bash" +#RustLog: "off" + +#EnvVar: { + ssm!: *null | string + default!: *null | string | int | bool | [...string] +} + +#EnvVars: { + set!: [string]: #EnvVar + get!: [...string] +} + +#Params: [...string] // todo: remove + +#Dir: { + env_var!: #EnvVars + params!: #Params +} + +".github": { + #Dir + codecov: { + flags: [...string] + } + workflows: { + env_var!: #EnvVars + params!: #Params + } +} + +#App: { + #Dir + runtime!: #Runtime + min_code_cov!: *null | int + type!: #AppType + local_dev!: *false | bool + deploy!: *true | bool + build_src_path!: *null | string + dependents!: [...string] + rust_log!: #RustLog +} + +client!: { + #Dir + runtime!: "v8" + min_code_cov!: null + type!: #AppType + local_dev!: *false | bool + deploy!: *true | bool +} + +#Lib: { + runtime!: #Runtime + min_code_cov!: *null | int + type!: #AppType + env_var!: #EnvVars + params!: #Params +} + +crates: { + #Dir + httpclient: #Lib + pg: #Lib + types: #Lib + uribuilder: #Lib + wsclient: #Lib +} + +docker: { + env_var!: #EnvVars +} + +infra: { + terraform: { + env_var!: #EnvVars + aws: { + environments: { + region: { + env_var!: #EnvVars + } + } + modules: { + env_var!: #EnvVars + environment: { + env_var!: #EnvVars + } + microk8s: { + env_var!: #EnvVars + } + "project-storage": { + env_var!: #EnvVars + } + } + } + } +} + +k8s: { + local: { + #Dir + type!: #AppType + } + dev: { + #Dir + type!: #AppType + } +} + +migrations: { + #Dir + type!: #AppType + dumps: { + env_var!: #EnvVars + } + "go-migrate": #App + testseed: { + env_var!: #EnvVars + } +} + +#Os: "osx" + +#Dir + +scripts!: { + env_var!: #EnvVars +} + +services: { + #Dir + graphql!: #App + "request-create": #App + "request-approve": #App + rule: #App + "request-by-id": #App + "requests-by-account": #App + "transaction-by-id": #App + "transactions-by-account": #App + "balance-by-account": #App + event: #App + measure: #App + "auto-confirm": #App +} + +tests: { + #Dir + runtime!: #Runtime + type!: #AppType + deploy: false +} + +#Os: "osx" + +#Tool: { + name!: string + os: [#Os]: { + install: string + } +} + +".tools": [...#Tool] \ No newline at end of file From 49e05846ac8ff97a4e780ca3f2fe6e32480be394 Mon Sep 17 00:00:00 2001 From: max funk Date: Fri, 27 Dec 2024 11:29:23 -0700 Subject: [PATCH 2/4] add properties required by cue file --- project.yaml | 53 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/project.yaml b/project.yaml index e7533a34..e4b62b2f 100644 --- a/project.yaml +++ b/project.yaml @@ -7,6 +7,7 @@ GITHUB_REPO_NAME: ssm: null default: mxfactorial + get: [] params: [] codecov: flags: @@ -25,6 +26,7 @@ DEPLOY_IMAGE_WORKFLOW: ssm: null default: deploy-all-images.yaml + get: [] params: [] client: runtime: v8 @@ -54,13 +56,17 @@ client: params: - ENABLE_API_AUTH crates: - env_var: null + env_var: + set: {} + get: [] params: [] httpclient: runtime: rust1.x min_code_cov: 55 type: lib - env_var: null + env_var: + set: {} + get: [] params: [] pg: runtime: rust1.x @@ -68,7 +74,7 @@ crates: type: lib params: [] env_var: - set: null + set: {} get: - PGHOST - PGPORT @@ -79,19 +85,25 @@ crates: runtime: rust1.x min_code_cov: 93 type: lib - env_var: null + env_var: + set: {} + get: [] params: [] uribuilder: runtime: rust1.x min_code_cov: 0 type: lib - env_var: null + env_var: + set: {} + get: [] params: [] wsclient: runtime: rust1.x min_code_cov: 0 type: lib - env_var: null + env_var: + set: {} + get: [] params: [] docker: env_var: @@ -102,6 +114,7 @@ docker: LOCAL_TAG_VERSION: ssm: null default: latest + get: [] infra: terraform: env_var: @@ -112,6 +125,7 @@ infra: TFSTATE_ENV_SUFFIX: ssm: null default: env_infra + get: [] aws: environments: region: @@ -120,12 +134,14 @@ infra: TFSTATE_APIGW_SUFFIX: ssm: null default: apigw_logging + get: [] modules: env_var: set: LAMBDA_RUNTIME: ssm: null default: provided.al2023 + get: [] environment: env_var: set: @@ -204,6 +220,7 @@ infra: READINESS_CHECK_PATH: ssm: service/lambda/readiness_check_path default: /healthz + get: [] microk8s: env_var: set: @@ -228,6 +245,7 @@ infra: MICROK8S_MANIFESTS_DIR: ssm: null default: k8s + get: [] project-storage: env_var: set: @@ -255,12 +273,13 @@ infra: TFSTATE_BUCKET_PREFIX: ssm: null default: mxfactorial-tfstate + get: [] k8s: local: type: lib params: [] env_var: - set: null + set: {} get: - CLIENT_PORT - PGPORT @@ -292,7 +311,7 @@ k8s: type: lib params: [] env_var: - set: null + set: {} get: - PGDATABASE - PGUSER @@ -330,6 +349,7 @@ migrations: TESTSEED_DUMP_PATH: ssm: null default: ./migrations/dumps/testseed.sql + get: [] go-migrate: runtime: bash min_code_cov: null @@ -339,9 +359,10 @@ migrations: - AWS_REGION deploy: true build_src_path: null - dependents: + dependents: [] + rust_log: off env_var: - set: [] + set: {} get: - SQL_TYPE - PGHOST @@ -355,6 +376,7 @@ migrations: TEST_ACCOUNTS_FILE: ssm: null default: ./migrations/testseed/000001_accounts.up.sql + get: [] scripts: env_var: set: @@ -412,6 +434,7 @@ scripts: SHORT_GIT_SHA_LENGTH: ssm: null default: 7 + get: [] services: env_var: set: @@ -424,6 +447,8 @@ services: RETURN_RECORD_LIMIT: ssm: null default: 20 + get: [] + params: [] graphql: runtime: rust1.x min_code_cov: null @@ -741,12 +766,14 @@ services: runtime: rust1.x min_code_cov: null type: app + local_dev: false params: [] deploy: true build_src_path: null dependents: [] rust_log: off env_var: + set: {} get: # used by make targets - POOL_ID - CLIENT_ID @@ -857,4 +884,8 @@ params: [] - name: ytt os: osx: - install: 'brew tap carvel-dev/carvel && brew install ytt' \ No newline at end of file + install: 'brew tap carvel-dev/carvel && brew install ytt' + - name: cue + os: + osx: + install: 'brew install cue-lang/tap/cue' \ No newline at end of file From 97f01f4facad150b0f2d64998dc0b93dfaf75c4c Mon Sep 17 00:00:00 2001 From: max funk Date: Fri, 27 Dec 2024 11:29:49 -0700 Subject: [PATCH 3/4] add cue workflow --- .github/workflows/project_conf.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/project_conf.yaml diff --git a/.github/workflows/project_conf.yaml b/.github/workflows/project_conf.yaml new file mode 100644 index 00000000..5f0f4b2c --- /dev/null +++ b/.github/workflows/project_conf.yaml @@ -0,0 +1,19 @@ +name: project-conf + +on: + push: + paths: + - project.yaml + +jobs: + conf_test: + name: test types in project.yaml + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cue-lang/setup-cue@v1.0.0 + with: + version: v0.11.1 + id: install + - name: test project.yaml + run: cue vet ./cue/project_conf.cue project.yaml \ No newline at end of file From f1f7322a8212d22ae592f6814fbf6b7eb49c44d4 Mon Sep 17 00:00:00 2001 From: max funk Date: Fri, 27 Dec 2024 11:30:03 -0700 Subject: [PATCH 4/4] add cue to devcontainers --- .devcontainer/Dockerfile | 5 +++++ docker/.gitpod.Dockerfile | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b152c6ff..958f11e2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,6 +4,7 @@ ARG TF_VERSION=1.2.7 ARG MIGRATE_VERSION=4.15.2 ARG WATCH_VERSION=8.4.0 ARG CARGO_LLVM_COV_VERSION=0.5.36 +ARG CUE_VERSION=0.11.1 RUN wget -O- https://carvel.dev/install.sh > install.sh && \ sudo bash install.sh && \ @@ -26,6 +27,10 @@ RUN wget -O- https://carvel.dev/install.sh > install.sh && \ tar -xf cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz && \ sudo mv cargo-llvm-cov /usr/local/bin && \ rm -rf cargo-llvm-cov* && \ + wget https://github.com/cue-lang/cue/releases/download/v${CUE_VERSION}/cue_v${CUE_VERSION}_linux_amd64.tar.gz && \ + tar -xf cue_v${CUE_VERSION}_linux_amd64.tar.gz && \ + sudo mv cue /usr/local/bin && \ + rm -rf cue_v${CUE_VERSION}_linux_amd64.tar.gz && \ npm install -g eslint && \ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && \ diff --git a/docker/.gitpod.Dockerfile b/docker/.gitpod.Dockerfile index d2707659..5710e716 100644 --- a/docker/.gitpod.Dockerfile +++ b/docker/.gitpod.Dockerfile @@ -1,6 +1,7 @@ FROM gitpod/workspace-full:latest ARG TF_VERSION=1.2.7 +ARG CUE_VERSION=0.11.1 RUN bash -lc "rustup default stable" && \ wget -O- https://carvel.dev/install.sh > install.sh && \ @@ -17,6 +18,10 @@ RUN bash -lc "rustup default stable" && \ unzip terraform_${TF_VERSION}_linux_amd64.zip && \ sudo mv terraform /usr/local/bin && \ rm terraform_${TF_VERSION}_linux_amd64.zip && \ + wget https://github.com/cue-lang/cue/releases/download/v${CUE_VERSION}/cue_v${CUE_VERSION}_linux_amd64.tar.gz && \ + tar -xf cue_v${CUE_VERSION}_linux_amd64.tar.gz && \ + sudo mv cue /usr/local/bin && \ + rm -rf cue_v${CUE_VERSION}_linux_amd64.tar.gz && \ rustup component add llvm-tools-preview --toolchain stable-x86_64-unknown-linux-gnu && \ cargo install cargo-llvm-cov && \ brew install libpq && \