Skip to content

Commit 3f309e5

Browse files
authored
Merge branch 'master' into fix5866
2 parents f58b895 + 8042969 commit 3f309e5

File tree

103 files changed

+2131
-2051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2131
-2051
lines changed

.github/workflows/integration-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
- '**'
1212
workflow_dispatch:
1313

14+
# Stack will use the value of the GH_TOKEN environment variable to authenticate
15+
# its requests of the GitHub REST API, providing a higher request rate limit.
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
1419
# As of 26 December 2022, ubuntu-latest, windows-latest and macos-latest come
1520
# with Stack 2.9.1. ubuntu-latest and macos-latest come with GHC 9.4.3.
1621
# windows-latest comes with GHC 9.4.2. windows-latest comes with NSIS 3.08, for

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Other enhancements:
2727

2828
* Better error message if the value of the `STACK_WORK` environment variable or
2929
`--work-dir` option is not a valid relative path.
30+
* Stack will use the value of the `GH_TOKEN`, or `GITHUB_TOKEN`, environment
31+
variable as credentials to authenticate its GitHub REST API requests.
32+
3033

3134
Bug fixes:
3235

doc/environment_variables.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
The environment variables listed in alphabetal order below can affect how Stack
66
behaves.
77

8+
## `GH_TOKEN` or `GITHUB_TOKEN`
9+
10+
:octicons-tag-24: UNRELEASED
11+
12+
Stack will use the value of the `GH_TOKEN` or, in the alternative,
13+
`GITHUB_TOKEN` environment variable (if not an empty string) as credentials to
14+
authenticate its requests of the GitHub REST API, using HTTP 'Basic'
15+
authentication.
16+
17+
GitHub limits the rate of unauthenticated requests to its API, although most
18+
users of Stack will not experience that limit from the use of Stack alone. The
19+
limit for authenticated requests is significantly higher.
20+
21+
For more information about authentication of requests of the GitHub REST API,
22+
see GitHub's REST API documentation.
23+
824
## `HACKAGE_KEY`
925

1026
[:octicons-tag-24: 2.7.5](https://github.com/commercialhaskell/stack/releases/tag/v2.7.5)

doc/global_flags.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ Default: `read-write`, if snapshot specified in YAML configuration file;
118118
`read-only`, if a different snapshot is specified on the command line.
119119

120120
Pass the option `--lock-file <mode>` to specify how Stack interacts with lock
121-
files. Valid modes are `error-on-write`, `ignore`, `read-only` and `read-write`.
121+
files. Valid modes are:
122+
123+
* `error-on-write`: Stack reports an error, rather than write a lock file;
124+
* `ignore`: Stack ignores lock files;
125+
* `read-only`: Stack only reads lock files; and
126+
* `read-write`: Stack reads and writes lock files.
122127

123128
## `--[no-]modify-code-page` flag
124129

doc/lock_files.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,40 @@ packages:
145145
sha256: 614bc0cca76937507ea0a5ccc17a504c997ce458d7f2f9e43b15a10c8eaeb033
146146
~~~
147147

148-
## Creation
148+
## Creation procedure
149149

150150
Whenever a project-level configuration file (`stack.yaml`) is loaded, Stack
151151
checks for a lock file in the same file path, with a `.lock` extension added.
152152
For example, if you command:
153153

154154
~~~text
155-
stack build --stack-yaml my-stack.yaml
155+
stack --stack-yaml my-stack.yaml build
156156
~~~
157157

158-
Stack will use a lock file in the location `my-stack.yaml.lock`. For the rest of
159-
this document, we'll assume that the files are simply `stack.yaml` and
158+
or
159+
160+
~~~text
161+
stack --stack-yaml my-stack.yaml build --dry-run
162+
~~~
163+
164+
then Stack will use a lock file in the location `my-stack.yaml.lock`. For the
165+
rest of this document, we'll assume that the files are simply `stack.yaml` and
160166
`stack.yaml.lock`.
161167

162-
If the lock file does not exist, it will be created by:
168+
If the lock file does not exist, subject to Stack's
169+
[`--lock-file`](global_flags.md#-lock-file-option) option, it will be
170+
created by:
163171

164172
* Loading the `stack.yaml`
165173
* Loading all snapshot files
166174
* Completing all missing information
167-
* Writing out the new `stack.yaml.lock` file
175+
* Writing out the new `stack.yaml.lock` file to the disk
168176

169177
## Update procedure
170178

171-
When loading a Stack project all completed package or snapshot locations (even
172-
when they were completed using information from a lock file) get collected to
173-
form a new lock file in memory and compare against the one on disk, writing if
174-
there are any differences.
179+
Whenever a project-level configuration file (`stack.yaml`) is loaded, all
180+
completed package or snapshot locations (even those completed using information
181+
from a lock file) get collected to form a new lock file in memory. Subject to
182+
Stack's [`--lock-file`](global_flags.md#-lock-file-option) option, that new lock
183+
file is compared against the one on disk and, if there are any differences,
184+
written out to the disk.

doc/pantry.md

Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -90,57 +90,55 @@ There are three types of package locations:
9090

9191
1. Hackage packages
9292
2. Git and Mecurial repositories
93-
3. Local or remote archives
93+
3. Local or remote archives (such as GitHub archives)
9494

9595
All three types support optional tree metadata to be added, which can be used
9696
for reproducibility and faster downloads. This information can automatically be
9797
generated in a [lock file](lock_files.md).
9898

9999
### Hackage packages
100100

101-
Packages can be stated by a name-version combination. The basic syntax for this
102-
is:
101+
A package can be identified by its name, version and Cabal file revision
102+
number, with revision `0` being the original Cabal file. For example:
103103

104104
~~~yaml
105105
extra-deps:
106-
- acme-missiles-0.3
106+
- acme-missiles-0.3@rev:0
107107
~~~
108108

109-
Using this syntax, the most recent Cabal file revision available will
110-
be used.
111-
112-
You can specify a specific revision number, with `0` being the original file,
113-
like this:
109+
A package name and version only can be stated. Using this syntax, the most
110+
recent Cabal file revision available in the package index will be used. For
111+
example:
114112

115113
~~~yaml
116114
extra-deps:
117-
- acme-missiles-0.3@rev:0
115+
- acme-missiles-0.3
118116
~~~
119117

120-
For safer, more reproducible builds, you can optionally specify the SHA256 hash
121-
of the Cabal file's contents, like this:
118+
This syntax is often used in practice, but may result in one build differing
119+
from another, if a new or further Cabal file revision is added to the package
120+
index between the builds.
121+
122+
As an alternative to specifying the Cabal file revision number, you can specify
123+
the package name and version with the SHA256 hash of the contents of its Cabal
124+
file. Doing so is slightly more resilient than using the Cabal file revision
125+
number, as it does not rely on the correct ordering in the package index.
126+
For example:
122127

123128
~~~yaml
124129
extra-deps:
125130
- acme-missiles-0.3@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1
126131
~~~
127132

128-
You can optionally also specify the size of the Cabal file in bytes, like this:
133+
Optionally, you can specify also the size of the Cabal file in bytes. For
134+
example (where the file size is `631` bytes):
129135

130136
~~~yaml
131137
extra-deps:
132138
- acme-missiles-0.3@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1,631
133139
~~~
134140

135-
!!! note
136-
137-
Specifying package using SHA256 is slightly more resilient in that it does
138-
not rely on correct ordering in the package index, while revision number is
139-
likely simpler to use. In practice, both should guarantee equally
140-
reproducible build plans.
141-
142-
You can also include the Pantry tree information. The following would be
143-
generated and stored in the lock file:
141+
Optionally, you can specify also the Pantry tree information. For example:
144142

145143
~~~yaml
146144
- hackage: acme-missiles-0.3@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1,613
@@ -149,10 +147,17 @@ generated and stored in the lock file:
149147
sha256: 614bc0cca76937507ea0a5ccc17a504c997ce458d7f2f9e43b15a10c8eaeb033
150148
~~~
151149

150+
The SHA256 hash of the contents of the Cabal file and its size in bytes is
151+
provided in Stack's lock file. For further information, see the
152+
[lock files](lock_files.md) documentation. The SHA256 hash and file size
153+
alternative is also what Stack uses when it makes suggestions about missing
154+
packages.
155+
152156
### Git and Mercurial repositories
153157

154-
You can give a Git or Mercurial repository at a specific commit, and Stack will
155-
clone that repository. For example:
158+
You can specify a Git or Mercurial repository at a specific commit, and Stack
159+
will clone that repository and, if it has submodules (Git), update the
160+
repository's submodules. For example:
156161

157162
~~~yaml
158163
extra-deps:
@@ -193,19 +198,6 @@ the root of the repository. If you specify a value of `subdirs`, then `'.'` is
193198
_not_ included by default and needs to be explicitly specified if a required
194199
package is found in the top-level directory of the repository.
195200

196-
#### GitHub
197-
198-
[:octicons-tag-24: 1.7.1](https://github.com/commercialhaskell/stack/releases/tag/v1.7.1)
199-
200-
You can specify packages from GitHub repository name using `github`. For
201-
example:
202-
203-
~~~yaml
204-
extra-deps:
205-
- github: snoyberg/http-client
206-
commit: a5f4f30f01366738f913968163d856366d7e0342
207-
~~~
208-
209201
#### git-annex
210202

211203
[git-annex](https://git-annex.branchable.com) is not supported. This is because
@@ -225,7 +217,9 @@ following line:
225217
fonts export-ignore
226218
~~~
227219

228-
### Local or remote archives
220+
### Local or remote archives (such as GitHub archives)
221+
222+
#### Filepaths or URLs to archive files
229223

230224
You can use filepaths referring to local archive files or HTTP or HTTPS URLs
231225
referring to remote archive files, either tarballs or ZIP files.
@@ -250,3 +244,27 @@ extra-deps:
250244
- archive: ../acme-missiles-0.3.tar.gz
251245
sha256: e563d8b524017a06b32768c4db8eff1f822f3fb22a90320b7e414402647b735b
252246
~~~
247+
248+
#### GitHub archive files
249+
250+
[:octicons-tag-24: 1.7.1](https://github.com/commercialhaskell/stack/releases/tag/v1.7.1)
251+
252+
You can specify a GitHub respository at a specific commit and Stack will obtain
253+
from GitHub an archive file of the files in the repository at that point in its
254+
history. For example:
255+
256+
~~~yaml
257+
extra-deps:
258+
- github: snoyberg/http-client
259+
commit: a5f4f30f01366738f913968163d856366d7e0342
260+
~~~
261+
262+
!!! note
263+
264+
An archive file of the files in a GitHub repository at a point in its
265+
history is not the same as a clone of the repository (including its history)
266+
and the updating of any submodules. If you need the latter, use the syntax
267+
for a [Git repository](pantry.md#git-and-mercurial-repositories).
268+
269+
If the package fails to build due to missing files, it may be that updated
270+
submodules are required.

package.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Hpack >= 0.35.0 is provided by Stack >= 2.9.1.
2+
spec-version: 0.35.0
3+
14
name: stack
25
version: '2.10.0'
36
synopsis: The Haskell Tool Stack
@@ -8,7 +11,7 @@ description: |
811
If building a 'stack' executable for distribution, please download the
912
source code from <https://github.com/commercialhaskell/stack/releases>
1013
and build it using Stack itself in order to ensure identical behaviour
11-
to official binaries. This package on Hackage is provided for convenience
14+
to official binaries. This package on Hackage is provided for convenience
1215
and bootstrapping purposes.
1316
.
1417
Note that the API for the library is not currently stable, and may
@@ -39,6 +42,8 @@ extra-source-files:
3942
- test/package-dump/ghc-head.txt
4043
- src/test/Stack/Untar/test1.tar.gz
4144
- src/test/Stack/Untar/test2.tar.gz
45+
# GHC's GHC2021 language extension is supported by GHC >= 9.2.1
46+
language: GHC2021
4247
ghc-options:
4348
- -fwrite-ide-info
4449
- -hiedir=.hie

src/Control/Concurrent/Execute.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
2-
{-# LANGUAGE DeriveDataTypeable #-}
32
{-# LANGUAGE RecordWildCards #-}
43

54
-- Concurrent execution with dependencies. Types currently hard-coded for needs

src/Data/Attoparsec/Args.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ argsParser mode = many (P.skipSpace *> (quoted <|> unquoted)) <*
3737
unquoted = P.many1 naked
3838
quoted = P.char '"' *> str <* P.char '"'
3939
str = many ( case mode of
40-
Escaping -> escaped <|> nonquote
41-
NoEscaping -> nonquote
40+
Escaping -> escaped <|> nonquote
41+
NoEscaping -> nonquote
4242
)
4343
escaped = P.char '\\' *> P.anyChar
4444
nonquote = P.satisfy (/= '"')

src/Data/Attoparsec/Combinators.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ module Data.Attoparsec.Combinators
1111
import Stack.Prelude
1212

1313
-- | Concatenate two parsers.
14-
appending :: (Applicative f, Semigroup a)
15-
=> f a -> f a -> f a
14+
appending ::
15+
(Applicative f, Semigroup a)
16+
=> f a
17+
-> f a
18+
-> f a
1619
appending a b = (<>) <$> a <*> b
1720

1821
-- | Alternative parsers.

0 commit comments

Comments
 (0)