Skip to content

Commit

Permalink
Merge branch 'cue-lang:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ngbinh authored Oct 2, 2024
2 parents e0b5216 + 5ffd573 commit ea05072
Show file tree
Hide file tree
Showing 100 changed files with 15,000 additions and 3,697 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache: false
go-version: 1.23.0
go-version: 1.23.2
- name: Set common go env vars
run: |-
go env -w GOTOOLCHAIN=local
Expand All @@ -80,11 +80,15 @@ jobs:
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: v2.2.0
version: v2.3.2
- name: Run GoReleaser with CUE
env:
CUE_LOGINS: ${{ secrets.NOTCUECKOO_CUE_LOGINS }}
GITHUB_TOKEN: ${{ secrets.CUECKOO_GITHUB_PAT }}
run: cue cmd release
run: |-
export CUE_CONFIG_DIR=$(mktemp -d)
echo "$CUE_LOGINS" > $CUE_CONFIG_DIR/logins.json
cue cmd release
working-directory: ./internal/ci/goreleaser
- name: Re-test cuelang.org
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/trybot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
uses: google-github-actions/setup-gcloud@v2
- name: End-to-end test
env:
CUE_TEST_LOGINS: ${{ secrets.E2E_CUE_LOGINS }}
CUE_TEST_LOGINS: ${{ secrets.E2E_PORCUEPINE_CUE_LOGINS }}
if: |-
github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
Expand Down Expand Up @@ -167,7 +167,12 @@ jobs:
exit 1
fi
- name: Generate
run: go generate ./...
env:
CUE_LOGINS: ${{ secrets.NOTCUECKOO_CUE_LOGINS }}
run: |-
export CUE_CONFIG_DIR=$(mktemp -d)
echo "$CUE_LOGINS" > $CUE_CONFIG_DIR/logins.json
go generate ./...
if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
- name: Check that git is clean at the end of the job
if: always()
Expand Down
8 changes: 7 additions & 1 deletion cmd/cue/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"net/http"
"os"
"time"

"github.com/spf13/cobra"
"golang.org/x/oauth2"
Expand Down Expand Up @@ -97,8 +98,13 @@ inside $CUE_CONFIG_DIR; see 'cue help environment'.
return fmt.Errorf("cannot obtain the OAuth2 token: %v", err)
}

_, err = cueconfig.UpdateRegistryLogin(loginsPath, host.Name, tok)
// For consistency, store timestamps in UTC.
tok.Expiry = tok.Expiry.UTC()
// OAuth2 measures expiry in seconds via the expires_in JSON wire format field,
// so any sub-second units add unnecessary verbosity.
tok.Expiry = tok.Expiry.Truncate(time.Second)

_, err = cueconfig.UpdateRegistryLogin(loginsPath, host.Name, tok)
if err != nil {
return fmt.Errorf("cannot store CUE registry logins: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cue/cmd/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func newMockRegistryOauth(mode string) *httptest.Server {
writeJSON(w, http.StatusOK, oauth2.Token{
AccessToken: staticAccessToken,
TokenType: "Bearer",
Expiry: time.Now().Add(time.Hour),
ExpiresIn: int64(time.Hour / time.Second), // 1h in seconds
})
default:
panic(fmt.Sprintf("unknown mode: %q", mode))
Expand Down
13 changes: 12 additions & 1 deletion cmd/cue/cmd/testdata/script/login_immediate.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ oauthregistry immediate-success

exec cue login
stdout 'open:.*user_code=user-code'
grep 'secret-access-token' cueconfig/logins.json

# Ensure that only one token is stored.
grep -count=1 '"registries": {' cueconfig/logins.json
grep -count=1 '"access_token"' cueconfig/logins.json

# Ensure the contents of the token look correct.
grep -count=1 '"access_token": "secret-access-token"' cueconfig/logins.json
grep -count=1 '"token_type": "Bearer"' cueconfig/logins.json
# Timestamps are always stored in UTC and truncated to seconds.
grep '"expiry": "20..-..-..T..:..:..Z"' cueconfig/logins.json
# oauthregistry does not give a refresh token, and we use encoding/json's omitempty.
! grep '"refresh_token"' cueconfig/logins.json
6 changes: 6 additions & 0 deletions cue.mod/module.cue
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ module: "cuelang.org/go"
language: {
version: "v0.8.0"
}
deps: {
"github.com/cue-tmp/jsonschema-pub/exp1/githubactions@v0": {
v: "v0.3.0"
default: true
}
}
Loading

0 comments on commit ea05072

Please sign in to comment.