Skip to content

Commit

Permalink
internal/ci: extract tip deploy steps to reusable steps
Browse files Browse the repository at this point in the history
This makes a subsequent introduction of a separate tipdeploy workflow
cleaner.

There is a slight re-ordering of Yaml output, but semantically it is a
meaningless diff.

Also name the npm install step in the hugo dir for cleaner logging on
the GitHub actions side.

Signed-off-by: Paul Jolly <[email protected]>
Change-Id: I69f3fb5fa8ad11c9fa11b569c746576ba491276e
  • Loading branch information
myitcv committed Dec 3, 2024
1 parent 5a279d6 commit 3c4dd10
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 50 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/trybot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ jobs:
if: always()
run: test -z "$(git status --porcelain)" || (git status; git diff; false)
- run: ./_scripts/buildDockerImage.bash
- run: npm install
- name: npm install in hugo dir
run: npm install
working-directory: hugo
- name: Test
run: go test ./...
Expand Down Expand Up @@ -233,18 +234,22 @@ jobs:
ALGOLIA_INDEX_FILE: ../_public/algolia.json
- name: 'tip.cuelang.org: Patch the site to be compatible with the tip of cue-lang/cue'
run: _scripts/tipPatchApply.bash
- name: 'tip.cuelang.org: Configure the site to use the tip of cue-lang/cue'
if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test'))
- if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test'))
name: npm install in hugo dir
run: npm install
working-directory: hugo
- if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test'))
name: 'tip.cuelang.org: Configure the site to use the tip of cue-lang/cue'
env:
GOPRIVATE: cuelang.org/go
run: _scripts/tipUseAlternativeCUE.bash
- name: 'tip.cuelang.org: Build the site against the tip of cue-lang/cue'
if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test'))
- if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test'))
name: 'tip.cuelang.org: Build the site against the tip of cue-lang/cue'
run: _scripts/regenPostInfraChange.bash
env:
GOPRIVATE: cuelang.org/go
- name: 'tip.cuelang.org: Deploy the site'
if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test'))
- if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test'))
name: 'tip.cuelang.org: Deploy the site'
run: |-
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:${{ secrets.CUECKOO_GITHUB_PAT }} | base64)"
_scripts/tipDeploy.bash 'cueckoo' '[email protected]'
Expand Down
98 changes: 55 additions & 43 deletions internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -222,49 +222,18 @@ workflows: trybot: _repo.bashWorkflow & {
}
},

githubactions.#Step & {
name: "tip.cuelang.org: Patch the site to be compatible with the tip of cue-lang/cue"
run: "_scripts/tipPatchApply.bash"
},

githubactions.#Step & {
name: "tip.cuelang.org: Configure the site to use the tip of cue-lang/cue"
// Only run in the main repo on the default branch or its designated test branch (i.e not CLs)
// so that CLs aren't blocked by failures caused by unrelated changes.
if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))"

// Force Go to bypass the module proxy and sumdb for the
// cuelang.org/go module, ensuring that the absolute latest CUE
// pseudo-version is available to test against.
//
// TODO: is this really necessary? Tracking
// https://golang.org/issue/70042 to confirm.
env: GOPRIVATE: "cuelang.org/go"

run: "_scripts/tipUseAlternativeCUE.bash"
},
githubactions.#Step & {
name: "tip.cuelang.org: Build the site against the tip of cue-lang/cue"
// Only run in the main repo on the default branch or its designated test branch (i.e not CLs)
// so that CLs aren't blocked by failures caused by unrelated changes.
if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))"
run: "_scripts/regenPostInfraChange.bash"

// TODO: See comment in previous step
env: GOPRIVATE: "cuelang.org/go"
},
githubactions.#Step & {
name: "tip.cuelang.org: Deploy the site"
// Only run in the main repo on the default branch or its designated test branch.
if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))"
run: """
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n \(_repo.botGitHubUser):${{ secrets.\(_repo.botGitHubUserTokenSecretsKey) }} | base64)"
_scripts/tipDeploy.bash '\(_repo.botGitHubUser)' '\(_repo.botGitHubUserEmail)'
"""

// TODO: See comment in previous step
env: GOPRIVATE: "cuelang.org/go"
},
// We do this on all branches to catch changes in a CL that cause the
// application of tip patches to fail. This doesn't guarantee later
// success, but it's a useful early indicator.
_applyTipPatches,

// npm install post applying of tip patches in case there is a
// relevant change in the patch affecting the result of npm install.
_ifMainRepoDefaultBranch & _npmInstall,

_ifMainRepoDefaultBranch & _useTipOfCUE,
_ifMainRepoDefaultBranch & _regenPostInfraChange,
_ifMainRepoDefaultBranch & _deployTipCuelangOrg,
]
}

Expand All @@ -286,6 +255,10 @@ workflows: trybot: _repo.bashWorkflow & {
}
}

_ifMainRepoDefaultBranch: githubactions.#Step & {
if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))"
}

_installNode: githubactions.#Step & {
name: "Install Node"
uses: "actions/setup-node@v4"
Expand Down Expand Up @@ -488,6 +461,45 @@ _porcuepineCueLogin: githubactions.#Step & {

// npm install in hugo to allow serve test to pass
_npmInstall: githubactions.#Step & {
name: "npm install in hugo dir"
run: "npm install"
"working-directory": "hugo"
}

_applyTipPatches: githubactions.#Step & {
name: "tip.cuelang.org: Patch the site to be compatible with the tip of cue-lang/cue"
run: "_scripts/tipPatchApply.bash"
}

_useTipOfCUE: githubactions.#Step & {
name: "tip.cuelang.org: Configure the site to use the tip of cue-lang/cue"

// Force Go to bypass the module proxy and sumdb for the
// cuelang.org/go module, ensuring that the absolute latest CUE
// pseudo-version is available to test against.
//
// TODO: is the use of GOPRIVATE (as opposed to GONOPROXY) really
// necessary? Tracking https://golang.org/issue/70042 to confirm.
env: GOPRIVATE: "cuelang.org/go"

run: "_scripts/tipUseAlternativeCUE.bash"
}

_regenPostInfraChange: githubactions.#Step & {
name: "tip.cuelang.org: Build the site against the tip of cue-lang/cue"
run: "_scripts/regenPostInfraChange.bash"

// TODO: See comment in previous step
env: GOPRIVATE: "cuelang.org/go"
}

_deployTipCuelangOrg: githubactions.#Step & {
name: "tip.cuelang.org: Deploy the site"
run: """
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n \(_repo.botGitHubUser):${{ secrets.\(_repo.botGitHubUserTokenSecretsKey) }} | base64)"
_scripts/tipDeploy.bash '\(_repo.botGitHubUser)' '\(_repo.botGitHubUserEmail)'
"""

// TODO: See comment in previous step
env: GOPRIVATE: "cuelang.org/go"
}

0 comments on commit 3c4dd10

Please sign in to comment.