@@ -51,27 +51,25 @@ installGo: {
51
51
[
52
52
#setupGo ,
53
53
54
- {
55
- githubactions .#Step & {
56
- name : " Set common go env vars "
57
- run : """
58
- go env -w GOTOOLCHAIN=local
59
-
60
- case $(go env GOARCH) in
61
- amd64) go env -w GOAMD64=v3 ;; # 2013 and later; makes `go test -race` 15% faster
62
- arm64) go env -w GOARM64=v8.6 ;; # Apple M2 and later
63
- esac
64
-
65
- # Dump env for good measure
66
- go env
67
- """
68
- }
54
+ githubactions .#Step & {
55
+ name : " Set common go env vars "
56
+ run : """
57
+ go env -w GOTOOLCHAIN=local
58
+
59
+ case $(go env GOARCH) in
60
+ amd64) go env -w GOAMD64=v3 ;; # 2013 and later; makes `go test -race` 15% faster
61
+ arm64) go env -w GOARM64=v8.6 ;; # Apple M2 and later
62
+ esac
63
+
64
+ # Dump env for good measure
65
+ go env
66
+ """
69
67
},
70
68
]
71
69
}
72
70
73
- checkoutCode : {
74
- #actionsCheckout : githubactions . #Step & {
71
+ checkoutCode : [... githubactions . #Step ] & [
72
+ {
75
73
name : " Checkout code "
76
74
uses : " actions/checkout@v4 " // TODO(mvdan): switch to namespacelabs/nscloud-checkout-action@v1 once Windows supports caching
77
75
@@ -84,64 +82,58 @@ checkoutCode: {
84
82
ref : " ${{ github.event.pull_request.head.sha }} "
85
83
" fetch-depth " : 0 // see the docs below
86
84
}
87
- }
85
+ },
88
86
89
- [
90
- #actionsCheckout ,
91
-
92
- // Restore modified times to work around https://go.dev/issues/58571,
93
- // as otherwise we would get lots of unnecessary Go test cache misses.
94
- // Note that this action requires actions/checkout to use a fetch-depth of 0.
95
- // Since this is a third-party action which runs arbitrary code,
96
- // we pin a commit hash for v2 to be in control of code updates.
97
- // Also note that git-restore-mtime does not update all directories,
98
- // per the bug report at https://github.com/MestreLion/git-tools/issues/47,
99
- // so we first reset all directory timestamps to a static time as a fallback.
100
- // TODO(mvdan): May be unnecessary once the Go bug above is fixed.
101
- githubactions .#Step & {
102
- name : " Reset git directory modification times "
103
- run : " touch -t 202211302355 $(find * -type d) "
104
- },
105
- githubactions .#Step & {
106
- name : " Restore git file modification times "
107
- uses : " chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe "
108
- },
87
+ // Restore modified times to work around https://go.dev/issues/58571,
88
+ // as otherwise we would get lots of unnecessary Go test cache misses.
89
+ // Note that this action requires actions/checkout to use a fetch-depth of 0.
90
+ // Since this is a third-party action which runs arbitrary code,
91
+ // we pin a commit hash for v2 to be in control of code updates.
92
+ // Also note that git-restore-mtime does not update all directories,
93
+ // per the bug report at https://github.com/MestreLion/git-tools/issues/47,
94
+ // so we first reset all directory timestamps to a static time as a fallback.
95
+ // TODO(mvdan): May be unnecessary once the Go bug above is fixed.
96
+ {
97
+ name : " Reset git directory modification times "
98
+ run : " touch -t 202211302355 $(find * -type d) "
99
+ },
100
+ {
101
+ name : " Restore git file modification times "
102
+ uses : " chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe "
103
+ },
109
104
110
- {
111
- githubactions .#Step & {
112
- name : " Try to extract \(dispatchTrailer ) "
113
- id : dispatchTrailerStepID
114
- run : """
115
- x="$(git log -1 --pretty='%(trailers:key=\(dispatchTrailer ),valueonly)')"
116
- if [[ "$x" == "" ]]
117
- then
118
- # Some steps rely on the presence or otherwise of the Dispatch-Trailer.
119
- # We know that we don't have a Dispatch-Trailer in this situation,
120
- # hence we use the JSON value null in order to represent that state.
121
- # This means that GitHub expressions can determine whether a Dispatch-Trailer
122
- # is present or not by checking whether the fromJSON() result of the
123
- # output from this step is the JSON value null or not.
124
- x=null
125
- fi
126
- echo "\(_dispatchTrailerDecodeStepOutputVar )<<EOD" >> $GITHUB_OUTPUT
127
- echo "$x" >> $GITHUB_OUTPUT
128
- echo "EOD" >> $GITHUB_OUTPUT
129
- """
130
- }
131
- },
105
+ {
106
+ name : " Try to extract \(dispatchTrailer ) "
107
+ id : dispatchTrailerStepID
108
+ run : """
109
+ x="$(git log -1 --pretty='%(trailers:key=\(dispatchTrailer ),valueonly)')"
110
+ if [[ "$x" == "" ]]
111
+ then
112
+ # Some steps rely on the presence or otherwise of the Dispatch-Trailer.
113
+ # We know that we don't have a Dispatch-Trailer in this situation,
114
+ # hence we use the JSON value null in order to represent that state.
115
+ # This means that GitHub expressions can determine whether a Dispatch-Trailer
116
+ # is present or not by checking whether the fromJSON() result of the
117
+ # output from this step is the JSON value null or not.
118
+ x=null
119
+ fi
120
+ echo "\(_dispatchTrailerDecodeStepOutputVar )<<EOD" >> $GITHUB_OUTPUT
121
+ echo "$x" >> $GITHUB_OUTPUT
122
+ echo "EOD" >> $GITHUB_OUTPUT
123
+ """
124
+ },
132
125
133
- // Safety nets to flag if we ever have a Dispatch-Trailer slip through the
134
- // net and make it to master
135
- githubactions .#Step & {
136
- name : " Check we don't have \(dispatchTrailer ) on a protected branch "
137
- if : " \(isProtectedBranch ) && \(containsDispatchTrailer ) "
138
- run : """
139
- echo "\(_dispatchTrailerVariable ) contains \(dispatchTrailer ) but we are on a protected branch"
140
- false
141
- """
142
- },
143
- ]
144
- }
126
+ // Safety nets to flag if we ever have a Dispatch-Trailer slip through the
127
+ // net and make it to master
128
+ {
129
+ name : " Check we don't have \(dispatchTrailer ) on a protected branch "
130
+ if : " \(isProtectedBranch ) && \(containsDispatchTrailer ) "
131
+ run : """
132
+ echo "\(_dispatchTrailerVariable ) contains \(dispatchTrailer ) but we are on a protected branch"
133
+ false
134
+ """
135
+ },
136
+ ]
145
137
146
138
earlyChecks : githubactions .#Step & {
147
139
name : " Early git and code sanity checks "
0 commit comments