Skip to content

Commit

Permalink
fix(ci): update scripts for new job db schema
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Oct 23, 2023
1 parent e46c925 commit b58d8cf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ci/plans/tests.cue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dagger.#Plan & {
AWS_REGION: Region
ENV_TAG: EnvTag
}
job: type: Test
spec: type: Test
}
}
}
53 changes: 34 additions & 19 deletions ci/utils/job.cue
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,28 @@ import (
}

#EpochTs: {
_cli: alpine.#Build & {
_deltaDays: string | *"+0"
_cli: alpine.#Build & {
packages: {
bash: {}
coreutils: {}
}
}
run: bash.#Run & {
input: _cli.output
always: true
env: DELTA_DAYS: _deltaDays
script: contents: #"""
echo -n "$(date +%s)000" > /epochTs
echo -n $(date +%s%N -d "$DELTA_DAYS days") > /epochNs
echo -n $(date +%s -d "$DELTA_DAYS days") > /epochS
"""#
export: files: {
"/epochTs": string
"/epochNs": string
"/epochS": string
}
}
epochTs: run.export.files["/epochTs"]
epochNs: run.export.files["/epochNs"]
epochS: run.export.files["/epochS"]
}

#Job: {
Expand All @@ -58,7 +64,7 @@ import (
ENV_TAG: string
}

job: {
spec: {
type: "deploy" | "anchor" | "test_e2e" | "test_smoke"
params: {
component: "ceramic" | "cas" | "ipfs" | *null
Expand All @@ -68,41 +74,50 @@ import (
}
}

_uuid: #Uuid
_epochTs: #EpochTs
_job: {
_uuid: #Uuid
_ts: #EpochTs
_ttl: #EpochTs & {
_deltaDays: "+14" // Two weeks
}
_spec: {
type: {
S: job.type
S: spec.type
}
stage: {
S: "queued"
}
id: {
S: "\(_uuid.uuid)"
}
job: {
S: "\(_uuid.uuid)"
}
ts: {
N: "\(_epochTs.epochTs)"
N: "\(_ts.epochNs)"
}
ttl: {
N: "\(_ttl.epochS)"
}
params: {
M: {
if job.params.component != null {
if spec.params.component != null {
component: {
S: job.params.component
S: spec.params.component
}
}
if job.params.sha != null {
if spec.params.sha != null {
sha: {
S: job.params.sha
S: spec.params.sha
}
}
if job.params.shaTag != null {
if spec.params.shaTag != null {
shaTag: {
S: job.params.shaTag
S: spec.params.shaTag
}
}
if job.params.version != null {
if spec.params.version != null {
version: {
S: job.params.version
S: spec.params.version
}
}
}
Expand All @@ -125,7 +140,7 @@ import (
"--table-name",
"ceramic-\(env.ENV_TAG)-ops",
"--item",
"'\(json.Marshal(_job))'",
"'\(json.Marshal(_spec))'",
]
}
}
Expand Down

0 comments on commit b58d8cf

Please sign in to comment.