ci: revert ci changes for now
Should fix the build.
Change-Id: I8438ffe6a6532dedd0093c776d8f6641203c3fd6
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6340
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/.github/workflows/gen.go b/.github/workflows/gen.go
new file mode 100644
index 0000000..440ab08
--- /dev/null
+++ b/.github/workflows/gen.go
@@ -0,0 +1,4 @@
+package workflows
+
+// Disable generation of this script for now.
+// go:generate go run cuelang.org/go/cmd/cue cmd genworkflows cuelang.org/go/internal/ci
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index e4fc9f9..4a281b5 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,8 +1,6 @@
# Generated by internal/ci/ci_tool.cue; do not edit
name: Test
-env:
- GERRIT_COOKIE: ${{ secrets.gerritCookie }}
defaults:
run:
shell: bash
@@ -14,17 +12,8 @@
- v*
jobs:
test:
- needs: start
runs-on: ${{ matrix.os }}
steps:
- - name: Set build branch env vars
- run: |-
- echo "::set-env name=CUE_IS_BUILD_BRANCH::$(echo $GITHUB_REF | grep -q '^refs\/heads\/[[:digit:]]\{14\}-I[0-9a-f]\+-[0-9a-f]\+-refs_changes_[[:digit:]]\{2\}_[[:digit:]]\+_[[:digit:]]\+$' && echo true || echo false)"
- echo "::set-env name=CUE_CHANGE_ID::$(echo $GITHUB_REF | cut -d '-' -f 2)"
- echo "::set-env name=CUE_COMMIT::$(echo $GITHUB_REF | cut -d '-' -f 3)"
- echo "::set-env name=CUE_REF::$(echo $GITHUB_REF | cut -d '-' -f 4 | sed 's/_/\//g')"
- - name: Write the gitcookies file
- run: echo "$GERRIT_COOKIE" > ~/.gitcookies
- name: Install Go
uses: actions/setup-go@v2
with:
@@ -57,12 +46,6 @@
cd $(mktemp -d)
go mod init mod.com
GOPROXY=https://proxy.golang.org go get -d cuelang.org/go@$v
- - name: Post any failures for this matrix entry
- if: ${{ env.CUE_IS_BUILD_BRANCH == 'true' && failure() }}
- run: 'curl -f -s -H "Content-Type: application/json" --request POST --data ''{"message":"Build
- failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url
- }}/actions/runs/${{ github.run_id }} for more details","labels":{"Code-Review":-1}}''
- -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/$CUE_CHANGE_ID/revisions/$CUE_COMMIT/review'
strategy:
matrix:
go-version:
@@ -74,36 +57,3 @@
- macos-latest
- windows-latest
fail-fast: false
- start:
- runs-on: ubuntu-latest
- steps:
- - name: Set build branch env vars
- run: |-
- echo "::set-env name=CUE_IS_BUILD_BRANCH::$(echo $GITHUB_REF | grep -q '^refs\/heads\/[[:digit:]]\{14\}-I[0-9a-f]\+-[0-9a-f]\+-refs_changes_[[:digit:]]\{2\}_[[:digit:]]\+_[[:digit:]]\+$' && echo true || echo false)"
- echo "::set-env name=CUE_CHANGE_ID::$(echo $GITHUB_REF | cut -d '-' -f 2)"
- echo "::set-env name=CUE_COMMIT::$(echo $GITHUB_REF | cut -d '-' -f 3)"
- echo "::set-env name=CUE_REF::$(echo $GITHUB_REF | cut -d '-' -f 4 | sed 's/_/\//g')"
- - name: Write the gitcookies file
- run: echo "$GERRIT_COOKIE" > ~/.gitcookies
- - name: Update Gerrit CL message with starting message
- if: ${{ env.CUE_IS_BUILD_BRANCH == 'true' }}
- run: 'curl -f -s -H "Content-Type: application/json" --request POST --data ''{"message":"Started
- the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{
- github.run_id }}"}'' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/$CUE_CHANGE_ID/revisions/$CUE_COMMIT/review'
- end:
- needs: test
- runs-on: ubuntu-latest
- steps:
- - name: Set build branch env vars
- run: |-
- echo "::set-env name=CUE_IS_BUILD_BRANCH::$(echo $GITHUB_REF | grep -q '^refs\/heads\/[[:digit:]]\{14\}-I[0-9a-f]\+-[0-9a-f]\+-refs_changes_[[:digit:]]\{2\}_[[:digit:]]\+_[[:digit:]]\+$' && echo true || echo false)"
- echo "::set-env name=CUE_CHANGE_ID::$(echo $GITHUB_REF | cut -d '-' -f 2)"
- echo "::set-env name=CUE_COMMIT::$(echo $GITHUB_REF | cut -d '-' -f 3)"
- echo "::set-env name=CUE_REF::$(echo $GITHUB_REF | cut -d '-' -f 4 | sed 's/_/\//g')"
- - name: Write the gitcookies file
- run: echo "$GERRIT_COOKIE" > ~/.gitcookies
- - name: Update Gerrit CL message with success message
- if: ${{ env.CUE_IS_BUILD_BRANCH == 'true' }}
- run: 'curl -f -s -H "Content-Type: application/json" --request POST --data ''{"message":"Build
- succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id
- }}","labels":{"Code-Review":1}}'' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/$CUE_CHANGE_ID/revisions/$CUE_COMMIT/review'
diff --git a/.github/workflows/test_dispatch.yml b/.github/workflows/test_dispatch.yml
index a1f3bb6..de3525e 100644
--- a/.github/workflows/test_dispatch.yml
+++ b/.github/workflows/test_dispatch.yml
@@ -1,29 +1,87 @@
# Generated by internal/ci/ci_tool.cue; do not edit
-name: Dispatch build branch
+name: Test
env:
- CUECKOO_PAT: ${{ secrets.cueckooPAT }}
+ GERRIT_COOKIE: ${{ secrets.gerritCookie }}
defaults:
run:
shell: bash
on:
- repository_dispatch
jobs:
- create_build_branch:
- runs-on: ubuntu-latest
+ test:
+ needs: start
+ runs-on: ${{ matrix.os }}
steps:
+ - name: Write the gitcookies file
+ run: echo "$GERRIT_COOKIE" > ~/.gitcookies
+ - name: Install Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout ref
run: |-
git fetch https://cue-review.googlesource.com/cue ${{ github.event.client_payload.ref }}
git checkout FETCH_HEAD
- - name: Create build branch
- run: |-
- git config user.email cueckoo@cuelang.org
- git config user.name cueckoo
- git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:$CUECKOO_PAT | base64)"
- ref=$(echo ${{ github.event.client_payload.ref }} | sed -e 's/\//_/g')
- branch="$(date -u +%Y%m%d%H%M%S)-${{ github.event.client_payload.changeID }}-${{ github.event.client_payload.commit }}-$ref"
- git checkout -b $branch
- git push origin $branch
+ - name: Cache Go modules
+ uses: actions/cache@v1
+ with:
+ path: ~/go/pkg/mod
+ key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum')
+ }}
+ restore-keys: ${{ runner.os }}-${{ matrix.go-version }}-go-
+ - name: Generate
+ if: matrix.go-version == '1.14.3' && matrix.os != 'windows-latest'
+ run: go generate ./...
+ - name: Test
+ run: go test ./...
+ - name: Test with -race
+ run: go test -race ./...
+ - name: gorelease check
+ if: matrix.go-version == '1.14.3' || matrix.go-version == '1.13.x'
+ run: go run golang.org/x/exp/cmd/gorelease
+ - name: Check that git is clean post generate and tests
+ run: test -z "$(git status --porcelain)" || (git status; git diff; false)
+ - name: Post any failures for this matrix entry
+ if: ${{ failure() }}
+ run: 'curl -f -s -H "Content-Type: application/json" --request POST --data ''{"message":"Build
+ failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url
+ }}/actions/runs/${{ github.run_id }} for more details","labels":{"Code-Review":-1}}''
+ -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/${{ github.event.client_payload.changeID
+ }}/revisions/${{ github.event.client_payload.commit }}/review'
+ strategy:
+ matrix:
+ go-version:
+ - 1.12.x
+ - 1.13.x
+ - 1.14.3
+ os:
+ - ubuntu-latest
+ - macos-latest
+ - windows-latest
+ fail-fast: false
+ start:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Write the gitcookies file
+ run: echo "$GERRIT_COOKIE" > ~/.gitcookies
+ - name: Update Gerrit CL message with starting message
+ run: 'curl -f -s -H "Content-Type: application/json" --request POST --data ''{"message":"Started
+ the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{
+ github.run_id }}"}'' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/${{
+ github.event.client_payload.changeID }}/revisions/${{ github.event.client_payload.commit
+ }}/review'
+ end:
+ needs: test
+ runs-on: ubuntu-latest
+ steps:
+ - name: Write the gitcookies file
+ run: echo "$GERRIT_COOKIE" > ~/.gitcookies
+ - name: Update Gerrit CL message with success message
+ run: 'curl -f -s -H "Content-Type: application/json" --request POST --data ''{"message":"Build
+ succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id
+ }}","labels":{"Code-Review":1}}'' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/${{
+ github.event.client_payload.changeID }}/revisions/${{ github.event.client_payload.commit
+ }}/review'
diff --git a/cue.mod/gen.go b/cue.mod/gen.go
new file mode 100644
index 0000000..1d10683
--- /dev/null
+++ b/cue.mod/gen.go
@@ -0,0 +1,3 @@
+package cuemod
+
+//go:generate go run cuelang.org/go/cmd/cue cmd vendorgithubschema cuelang.org/go/internal/ci
diff --git a/gen.go b/gen.go
new file mode 100644
index 0000000..cf14afe
--- /dev/null
+++ b/gen.go
@@ -0,0 +1,3 @@
+package cue
+
+//go:generate go generate ./.github/workflows
diff --git a/internal/ci/ci_tool.cue b/internal/ci/ci_tool.cue
index 1f32fcf..b150255 100644
--- a/internal/ci/ci_tool.cue
+++ b/internal/ci/ci_tool.cue
@@ -2,13 +2,15 @@
import (
"tool/file"
+ "tool/http"
+ "tool/exec"
"encoding/yaml"
)
-command: gengithub: task: {
+command: genworkflows: task: {
for w in workflows {
"\(w.file)": file.Create & {
- filename: "../../.github/workflows/\(w.file)"
+ filename: w.file
contents: """
# Generated by internal/ci/ci_tool.cue; do not edit
@@ -17,3 +19,16 @@
}
}
}
+
+// vendorgithubschema is expected to be run within the cuelang.org/go
+// cue.mod directory
+command: vendorgithubschema: {
+ get: http.Get & {
+ request: body: ""
+ url: "https://raw.githubusercontent.com/SchemaStore/schemastore/f7a0789ccb3bd74a720ddbd6691d60fd9e2d8b7a/src/schemas/json/github-workflow.json"
+ }
+ convert: exec.Run & {
+ stdin: get.response.body
+ cmd: "go run cuelang.org/go/cmd/cue import -f -p json -l #Workflow: jsonschema: - --outfile pkg/github.com/SchemaStore/schemastore/src/schemas/json/github-workflow.cue"
+ }
+}
diff --git a/internal/ci/gen.go b/internal/ci/gen.go
deleted file mode 100644
index e5644ae..0000000
--- a/internal/ci/gen.go
+++ /dev/null
@@ -1,3 +0,0 @@
-package ci
-
-//go:generate go run cuelang.org/go/cmd/cue cmd gengithub .
diff --git a/internal/ci/workflows.cue b/internal/ci/workflows.cue
index 437febe..6d2d564 100644
--- a/internal/ci/workflows.cue
+++ b/internal/ci/workflows.cue
@@ -110,14 +110,38 @@
}
test: json.#Workflow & {
- #setCUEEnv: #step & {
- name: "Set build branch env vars"
- run: #"""
- echo "::set-env name=CUE_IS_BUILD_BRANCH::$(echo $GITHUB_REF | grep -q '^refs\/heads\/[[:digit:]]\{14\}-I[0-9a-f]\+-[0-9a-f]\+-refs_changes_[[:digit:]]\{2\}_[[:digit:]]\+_[[:digit:]]\+$' && echo true || echo false)"
- echo "::set-env name=CUE_CHANGE_ID::$(echo $GITHUB_REF | cut -d '-' -f 2)"
- echo "::set-env name=CUE_COMMIT::$(echo $GITHUB_REF | cut -d '-' -f 3)"
- echo "::set-env name=CUE_REF::$(echo $GITHUB_REF | cut -d '-' -f 4 | sed 's/_/\//g')"
- """#
+ name: "Test"
+ on: {
+ push: {
+ branches: ["*"]
+ "tags-ignore": ["v*"]
+ }
+ }
+ defaults: run: shell: "bash"
+ jobs: test: {
+ strategy: #testStrategy
+ "runs-on": "${{ matrix.os }}"
+ steps: [
+ #installGo,
+ #checkoutCode,
+ #cacheGoModules,
+ #goGenerate,
+ #goTest,
+ #goTestRace,
+ #goReleaseCheck,
+ #checkGitClean,
+ #pullThroughProxy,
+ ]
+ }
+}
+
+test_dispatch: json.#Workflow & {
+ #checkoutRef: #step & {
+ name: "Checkout ref"
+ run: """
+ git fetch https://cue-review.googlesource.com/cue ${{ github.event.client_payload.ref }}
+ git checkout FETCH_HEAD
+ """
}
#writeCookiesFile: #step & {
name: "Write the gitcookies file"
@@ -132,28 +156,21 @@
}
}
res: #"""
- curl -f -s -H "Content-Type: application/json" --request POST --data '\#(encjson.Marshal(#args))' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/$CUE_CHANGE_ID/revisions/$CUE_COMMIT/review
+ curl -f -s -H "Content-Type: application/json" --request POST --data '\#(encjson.Marshal(#args))' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/${{ github.event.client_payload.changeID }}/revisions/${{ github.event.client_payload.commit }}/review
"""#
}
}
- env: GERRIT_COOKIE: "${{ secrets.gerritCookie }}"
name: "Test"
- on: {
- push: {
- branches: ["*"]
- "tags-ignore": ["v*"]
- }
- }
+ env: GERRIT_COOKIE: "${{ secrets.gerritCookie }}"
+ on: ["repository_dispatch"]
defaults: run: shell: "bash"
jobs: {
start: {
"runs-on": "ubuntu-latest"
steps: [
- #setCUEEnv,
#writeCookiesFile,
#step & {
- if: "${{ env.CUE_IS_BUILD_BRANCH == 'true' }}"
name: "Update Gerrit CL message with starting message"
run: (#gerrit.#setCodeReview & {
#args: message: "Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}"
@@ -162,23 +179,20 @@
]
}
test: {
- needs: "start"
- strategy: #testStrategy
"runs-on": "${{ matrix.os }}"
steps: [
- #setCUEEnv,
#writeCookiesFile,
#installGo,
#checkoutCode,
+ #checkoutRef,
#cacheGoModules,
#goGenerate,
#goTest,
#goTestRace,
#goReleaseCheck,
#checkGitClean,
- #pullThroughProxy,
#step & {
- if: "${{ env.CUE_IS_BUILD_BRANCH == 'true' && failure() }}"
+ if: "${{ failure() }}"
name: "Post any failures for this matrix entry"
run: (#gerrit.#setCodeReview & {
#args: {
@@ -190,14 +204,14 @@
}).res
},
]
+ needs: "start"
+ strategy: #testStrategy
}
end: {
"runs-on": "ubuntu-latest"
steps: [
- #setCUEEnv,
#writeCookiesFile,
#step & {
- if: "${{ env.CUE_IS_BUILD_BRANCH == 'true' }}"
name: "Update Gerrit CL message with success message"
run: (#gerrit.#setCodeReview & {
#args: {
@@ -213,41 +227,6 @@
}
}
}
-
-test_dispatch: json.#Workflow & {
- env: CUECKOO_PAT: "${{ secrets.cueckooPAT }}"
- name: "Dispatch build branch"
- on: ["repository_dispatch"]
- defaults: run: shell: "bash"
- jobs: {
- create_build_branch: {
- "runs-on": "ubuntu-latest"
- steps: [
- #checkoutCode,
- #step & {
- name: "Checkout ref"
- run: """
- git fetch https://cue-review.googlesource.com/cue ${{ github.event.client_payload.ref }}
- git checkout FETCH_HEAD
- """
- },
- #step & {
- name: "Create build branch"
- run: #"""
- git config user.email cueckoo@cuelang.org
- git config user.name cueckoo
- git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:$CUECKOO_PAT | base64)"
- ref=$(echo ${{ github.event.client_payload.ref }} | sed -e 's/\//_/g')
- branch="$(date -u +%Y%m%d%H%M%S)-${{ github.event.client_payload.changeID }}-${{ github.event.client_payload.commit }}-$ref"
- git checkout -b $branch
- git push origin $branch
- """#
- },
- ]
- }
- }
-}
-
release: {
name: "Release"
on: push: tags: ["v*"]
diff --git a/internal/deps/deps_tool.cue b/internal/deps/deps_tool.cue
deleted file mode 100644
index c6d5ebd..0000000
--- a/internal/deps/deps_tool.cue
+++ /dev/null
@@ -1,22 +0,0 @@
-package deps
-
-import (
- "tool/http"
- "tool/exec"
- "strings"
-)
-
-command: vendorgithubschema: {
- get: http.Get & {
- request: body: ""
- url: "https://raw.githubusercontent.com/SchemaStore/schemastore/f7a0789ccb3bd74a720ddbd6691d60fd9e2d8b7a/src/schemas/json/github-workflow.json"
- }
- root: exec.Run & {
- cmd: "go list -m -f {{.Dir}}"
- stdout: string
- }
- convert: exec.Run & {
- stdin: get.response.body
- cmd: "go run cuelang.org/go/cmd/cue import -f -p json -l #Workflow: jsonschema: - --outfile \(strings.TrimSpace(root.stdout))/cue.mod/pkg/github.com/SchemaStore/schemastore/src/schemas/json/github-workflow.cue"
- }
-}
diff --git a/internal/deps/gen.go b/internal/deps/gen.go
deleted file mode 100644
index dff3ef9..0000000
--- a/internal/deps/gen.go
+++ /dev/null
@@ -1,3 +0,0 @@
-package deps
-
-//go:generate go run cuelang.org/go/cmd/cue cmd vendorgithubschema .