@@ -6,42 +6,6 @@ The specification aims to clarify how `ghasum` operates. Any discrepancy with
66the implementation or ambiguity in the specification can be reported as a bug.
77There is no guarantee on whether the specification or implementation is correct.
88
9- ## Scope
10-
11- The scope of ` ghasum ` are reusable GitHub Actions used in the GitHub Actions
12- Workflow of a repository. This excludes
13-
14- - Actions in the same repository as the workflow ("local actions"). Example:
15-
16- ``` yaml
17- steps :
18- - uses : ./.github/actions/hello-world-action
19- ` ` `
20-
21- - Docker Hub Actions ([#216]). Examples:
22-
23- ` ` ` yaml
24- steps :
25- - uses : docker://alpine:3.8
26- - uses : docker://ghcr.io/OWNER/IMAGE_NAME
27- - uses : docker://gcr.io/cloud-builders/gradle
28- ` ` `
29-
30- - Reusable workflows ([#215]). Examples:
31-
32- ` ` ` yaml
33- jobs :
34- call-workflow-1-in-local-repo :
35- uses : octo-org/this-repo/.github/workflows/workflow-1.yml@172239021f7ba04fe7327647b213799853a9eb89
36- call-workflow-2-in-local-repo :
37- uses : ./.github/workflows/workflow-2.yml
38- call-workflow-in-another-repo :
39- uses : octo-org/another-repo/.github/workflows/workflow.yml@v1
40- ` ` `
41-
42- [#215]: https://github.com/chains-project/ghasum/issues/215
43- [#216]: https://github.com/chains-project/ghasum/issues/216
44-
459## Actions
4610
4711### ` ghasum init `
@@ -54,10 +18,11 @@ immediately (it means either 1. the file has been created since it was checked
5418and so is not owned by us, or 2. the file could not be created and so cannot be
5519initialized).
5620
57- If the file lock is obtained, the process will compute checksums for all actions
58- used in the repository (see [Computing Checksums]) using the best available
59- hashing algorithm. Then it stores them in a sumfile (see [Storing Checksums])
60- using the latest sumfile version and releases the lock.
21+ If the file lock is obtained, the process will compute checksums (see [ Computing
22+ Checksums] ) for all actions used in the repository (see [ Collecting Actions] )
23+ using the best available hashing algorithm. Then it stores them in a sumfile
24+ (see [ Storing Checksums] ) using the latest sumfile version. Finally the process
25+ will releases the lock on the file.
6126
6227If the process fails an attempt should be made to remove the created file (if
6328removing fails the error is ignored).
@@ -74,14 +39,14 @@ by another process leading to an inconsistent state).
7439If the file lock is obtained, the process shall first read it and parse it
7540completely to extract the sumfile version. If this fails the process shall exit
7641immediately unless the ` -force ` flag is used (see details below). Else it shall
77- compute checksums for all new actions used in the repository (see [Computing
78- Checksums ]) using the best available hashing algorithm. Here, a new action also
79- includes a new version of a previously used action. Additionally, it should
80- remove any entry which is no longer in use. No existing checksum for a used
81- action shall be updated unless the `-force` flag is used. It shall then store
82- them in a sumfile (see [Storing Checksums]) using the same sumfile version as
83- before and releases the lock. In short, updating will only add new and remove
84- old checksums from an existing sumfile.
42+ compute checksums (see [ Computing Checksums ] ) for all new actions used in the
43+ repository (see [ Collecting Actions ] ) using the same hashing algorithm as was
44+ used for the existing checksums. New actions also include new versions of a
45+ previously used actions. Additionally, it should remove any entry which is no
46+ longer in use. No existing checksum for a used action shall be updated. It shall
47+ then store them in a sumfile (see [ Storing Checksums] ) using the same sumfile
48+ version as before and releases the lock. In short, updating will only add new
49+ and remove old checksums from an existing sumfile.
8550
8651With the ` -force ` flag the process will ignore errors in the sumfile and fix
8752those while updating. It will also update existing checksums that are incorrect.
9964
10065If the checksum file exists the process shall read and parse it fully. If this
10166fails the process shall exit immediately. Else it shall recompute the checksums
102- (see [Computing Checksums]) for all actions in the target using the same hashing
103- algorithm as was used for the stored checksums. It shall compare the computed
104- checksums against the stored checksums.
67+ (see [ Computing Checksums] ) for all actions in the target (see [ Collecting
68+ Actions ] ) using the same hashing algorithm as was used for the stored checksums.
69+ It shall compare the computed checksums against the stored checksums.
10570
10671If any of the checksums does not match or is missing the process shall exit with
10772a non-zero exit code, for usability all values should be compared (and all
@@ -117,6 +82,51 @@ Redundant checksums are ignored by this process.
11782
11883## Procedures
11984
85+ ### Collecting Actions
86+
87+ To determine the set of actions a target depends on, first find all ` uses: `
88+ entries in the target. For a repository this covers all workflows in the
89+ workflows directory, otherwise it covers only the target.
90+
91+ For each ` uses: ` value, excluding the list below, it is added to the set and the
92+ repository declared by the ` uses: ` value is fetched. The action manifest at the
93+ path specified in the ` uses: ` value is parsed for additional ` uses: ` values. For
94+ each of these transitive ` uses: ` values, this process is repeated.
95+
96+ The following ` uses: ` values are to be excluded from the set of actions a
97+ repository depends on.
98+
99+ - Actions in the same repository as the workflow ("local actions"). Example:
100+
101+ ``` yaml
102+ steps :
103+ - uses : ./.github/actions/hello-world-action
104+ ` ` `
105+
106+ - Docker Hub Actions ([#216]). Examples:
107+
108+ ` ` ` yaml
109+ steps :
110+ - uses : docker://alpine:3.8
111+ - uses : docker://ghcr.io/OWNER/IMAGE_NAME
112+ - uses : docker://gcr.io/cloud-builders/gradle
113+ ` ` `
114+
115+ - Reusable workflows ([#215]). Examples:
116+
117+ ` ` ` yaml
118+ jobs :
119+ call-workflow-1-in-local-repo :
120+ uses : octo-org/this-repo/.github/workflows/workflow-1.yml@172239021f7ba04fe7327647b213799853a9eb89
121+ call-workflow-2-in-local-repo :
122+ uses : ./.github/workflows/workflow-2.yml
123+ call-workflow-in-another-repo :
124+ uses : octo-org/another-repo/.github/workflows/workflow.yml@v1
125+ ` ` `
126+
127+ [#215]: https://github.com/chains-project/ghasum/issues/215
128+ [#216]: https://github.com/chains-project/ghasum/issues/216
129+
120130### Computing Checksums
121131
122132To compute checksums ` ghasum` will pull the repository of an action, either at
@@ -181,8 +191,12 @@ version 1
181191
182192# # Definitions
183193
194+ - _action manifest_ is the file `action.yml` or `action.yaml` (mutually
195+ exclusive).
184196- _checksum file_ is the file `.github/workflows/gha.sum`.
197+ - _workflows directory_ is the directory `.github/workflows`.
185198
199+ [collecting actions] : # collecting-actions
186200[computing checksums] : # computing-checksums
187201[storing checksums] : # storing-checksums
188202[sumfile versions] : # sumfile-versions
0 commit comments