Skip to content

Commit

Permalink
chore(.github): Document and explain CI override directives (#10318)
Browse files Browse the repository at this point in the history
## Description
Updates inline comments in GitHub actions files to explain CI override directives (`#endo-branch`, `#getting-started-branch`, etc.) and adds references to them in the PR template to reduce our dependence upon oral tradition.

Also, although out of scope for this PR and probably not needed, we might consider a future change to pull out a helper for consumption of such directives:

<details><summary>.github/**/*.yml</summary>

```patch
       - name: Get the appropriate dapp branch
         id: get-branch
-        uses: actions/github-script@v7
+        uses: ./.github/actions/read-pr-directive
         with:
-          result-encoding: string
-          script: |
-            let branch = 'main';
-            if (context.payload.pull_request) {
-              const { body } = context.payload.pull_request;
-              const regex = /^\#getting-started-branch:\s+(\S+)/m;
-              const result = regex.exec(body);
-              if (result) {
-                branch = result[1];
-              }
-            }
-            console.log('getting-started dapp branch: ' + branch);
-            return branch;
+          tag: '#getting-started-branch'
+          default-value: main
```

</details>
<details><summary>.github/actions/read-pr-directive</summary>

```yaml
name: Read PR Directive
description: 'Read the value of a `#`-prefixed directive from a PR description'

inputs:
  tag:
    description: 'The directive tag to read (must start with `#`)'
    required: true
  default-value:
    description: 'The value to return in the absence of any overriding directive'
    required: true

outputs:
  result:
    description: >-
      The value of the last overriding directive, or the default value if the
      context is not a pull request or there is no such directive
    value: ${{ steps.script.outputs.result }}

runs:
  using: composite
  steps:
    - id: script
      uses: actions/github-script@v7
      env:
        TAG: ${{ inputs.tag }}
        DEFAULT_VALUE: ${{ inputs.default-value }}
      with:
        result-encoding: string
        script: |-
          const q = JSON.stringify;
          const { TAG, DEFAULT_VALUE } = process.env;
          if (!TAG.startsWith('#')) {
            throw Error(`malformed directive tag ${q(TAG)}`);
          }
          if (!context.payload.pull_request) return DEFAULT_VALUE;

          const { body } = context.payload.pull_request;
          const directives = body.matchAll(/^(\#[\w-]+):\s+(\S+)/gm);
          const selections = directives.filter(m => m[1] === TAG).map(m => m[2]);
          const selection = selections.pop();
          for (const ignored of selections) {
            console.warn(`ignoring ${q(`${TAG}: ${ignored}`)}`);
          }
          console.log(`${TAG}: ${selection}`);
          return selection || DEFAULT_VALUE;
```

</details>

### Security Considerations
n/a

### Scaling Considerations
n/a

### Documentation Considerations
:ballot_box_with_check:

### Testing Considerations
n/a

### Upgrade Considerations
n/a
  • Loading branch information
mergify[bot] authored Oct 25, 2024
2 parents 823c8d1 + d69e965 commit 3007c00
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
11 changes: 10 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
v ✰ Thanks for creating a PR! ✰
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->

<!-- Most PRs should close a specific Issue. All PRs should at least reference one or more Issues. Edit and/or delete the following lines as appropriate (note: you don't need both `refs` and `closes` for the same one): -->
<!-- Most PRs should close a specific issue. All PRs should at least reference one or more issues. Edit and/or delete the following lines as appropriate (note: you don't need both `refs` and `closes` for the same one): -->

closes: #XXXX
refs: #XXXX

<!-- Integration testing generally doesn't run until a PR is labeled for merge, but can be opted into for every push by adding label 'force:integration', and can be customized to use non-default external targets by including lines here that **start** with leading-`#` directives:
* (https://github.com/Agoric/documentation) #documentation-branch: $BRANCH_NAME
* (https://github.com/endojs/endo) #endo-branch: $BRANCH_NAME
* (https://github.com/Agoric/dapp-offer-up) #getting-started-branch: $BRANCH_NAME
* (https://github.com/Agoric/testnet-load-generator) #loadgen-branch: $BRANCH_NAME
These directives should be removed before adding a merge label, so final integration tests run against default targets.
-->

## Description
<!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. -->

Expand Down
15 changes: 8 additions & 7 deletions .github/actions/restore-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ runs:
persist-credentials: false
path: ${{ inputs.path }}

# Select a branch on Endo to test against by adding text to the body of the
# pull request. For example: #endo-branch: some-pr-branch
# The default is 'NOPE' to indicate not to check out Endo, just use
# the published NPM packages.
# Select an Endo target against which to test, defaulting to 'NOPE' for use
# of internally-referenced NPM packages but allowing overrides in the pull
# request description for referencing a branch of the
# [endo repository](https://github.com/endojs/endo) using lines like
# `#endo-branch: rank-strings-by-codepoint`
- name: Get the appropriate Endo branch
id: endo-branch
uses: actions/github-script@v7
Expand All @@ -53,8 +54,8 @@ runs:
script: |-
let branch = 'NOPE';
if (${{ inputs.ignore-endo-branch }}) {
// Skip endo branch
} else if (context.eventName === 'schedule') {
// Skip any override directive.
} else if (context.eventName === 'schedule') {
branch = 'master';
} else if (context.payload.pull_request) {
const { body } = context.payload.pull_request;
Expand Down Expand Up @@ -85,7 +86,7 @@ runs:
if: steps.endo-branch.outputs.result != 'NOPE'
uses: actions/checkout@v4
with:
repository: agoric/endo
repository: endojs/endo
path: ./replacement-endo
ref: ${{ steps.endo-branch.outputs.result }}
clean: 'false'
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ jobs:
pre_check:
uses: ./.github/workflows/pre-check-integration.yml

# This job is meant to emulate what developers working with the Agoric platform will experience
# It should be kept in sync with https://agoric.com/documentation/getting-started/
# This job is meant to emulate what developers working with the Agoric
# platform will experience.
# It should be kept in sync with the "getting started" workflow at
# https://docs.agoric.com/guides/getting-started/
getting-started:
needs: pre_check
if: needs.pre_check.outputs.should_run == 'true'
Expand All @@ -60,9 +62,11 @@ jobs:
node-version: 18.18
keep-endo: 'true'

# Select a branch on dapp to test against by adding text to the body of the
# pull request. For example: #getting-started-branch: zoe-release-0.7.0
# The default is 'main'
# Select a branch of the
# [default dapp repository](https://github.com/Agoric/dapp-offer-up) (cf.
# packages/agoric-cli/src/main.js) against which to test, defaulting to
# 'main' but allowing overrides in the pull request description using
# lines like `#getting-started-branch: zoe-release-0.7.0`
- name: Get the appropriate dapp branch
id: get-branch
uses: actions/github-script@v7
Expand Down Expand Up @@ -138,9 +142,10 @@ jobs:
# the chances the content of snapshots may deviate between validators
xsnap-random-init: '1'

# Select a branch on loadgen to test against by adding text to the body of the
# pull request. For example: #loadgen-branch: user-123-update-foo
# The default is 'main'
# Select a branch of the
# [load generator dapp repository](https://github.com/Agoric/testnet-load-generator)
# to use, defaulting to 'main' but allowing overrides in the pull request
# description using lines like `#loadgen-branch: ceelab`
- name: Get the appropriate loadgen branch
id: get-loadgen-branch
uses: actions/github-script@v7
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ jobs:
node-version: ${{ matrix.node-version }}
path: ./agoric-sdk

# Select a branch on dapp to test against by adding text to the body of the
# pull request. For example: #dapp-encouragement-branch: zoe-release-0.7.0
# The default is 'main'
# Select a branch of the
# [documentation repository](https://github.com/Agoric/documentation)
# against which to test, defaulting to 'main' but allowing overrides in
# the pull request description using lines like
# `#documentation-branch: node-22`
- name: Get the appropriate dapp branch
id: get-branch
uses: actions/github-script@v7
Expand All @@ -44,7 +46,7 @@ jobs:
branch = result[1];
}
}
console.log(branch);
console.log('documentation branch: ' + branch);
return branch;
- name: Check out dapp
Expand Down

0 comments on commit 3007c00

Please sign in to comment.