Skip to content

Commit

Permalink
Merge branch 'master' of github.com:w3f/Grant-Milestone-Delivery
Browse files Browse the repository at this point in the history
  • Loading branch information
Noc2 committed Dec 7, 2021
2 parents e09a8ca + 3132304 commit 5c57fe9
Show file tree
Hide file tree
Showing 21 changed files with 438 additions and 123 deletions.
1 change: 0 additions & 1 deletion .actrc

This file was deleted.

1 change: 0 additions & 1 deletion .env

This file was deleted.

37 changes: 1 addition & 36 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1 @@
# Testing workflows

While it requires some assumptions & is somewhat limited in scope, it's possible to run local testing on some of the workflows

## Setup
0. Setup your Google API Credentials on https://console.developers.google.com/
- Credentials -> Create Credentials -> Service Accounts

1. Follow the instructions for installing [act](https://github.com/nektos/act)

2. The act environment is configured via `.actrc` & `.env` files. For this repo, we set:
- the docker image used for testing to `nektos/act-environments-ubuntu:18.04`, corresponding to GitHub's test environment. Probably not all features are necessary, but we rely for example on the presence of `jq` in the image for JSON parsing
- `ACT=true` environment variable. This way we can distinguish which steps to run

3. Pull the above mentioned docker image:
`docker pull nektos/act-environments-ubuntu:18.04`

### Local Testing

4. Modify the `google_sheet_update.yml` to replace the `parse files` section with `local testing parse files` (since they have the same ID, they can't both be used in the yml or else GitHub will complain). They should both be there by default, it's just a matter of commenting one section out

### Fork Testing
4. Fork the Open Grants Repo

5. Set up your secrets under the fork/settings:
- GSHEET_PRIVATE_KEY
- GSHEET_CLIENT_EMAIL
- SPREADSHEET_ID

6. Branch off from master. Create a PR with only 1 file added (e.g. `cp deliveries/.delivery_testing.md deliveries/.delivery_testing_2.md`, add & commit it). To trigger the workflow, you need to merge the PR (into your own fork). Note: Push any changes to fork's master branch before you branch off, because the workflow to run will be the one from master.

## Usage

```
act -s GSHEET_PRIVATE_KEY="$(< .gsheet_private_key)" -s GSHEET_CLIENT_EMAIL="$(< .gsheet_client_email)" -s SPREADSHEET_ID="$(< .spreadsheet_id)" -e .pr_event.json -j update_sheet
```
Basic instructions on workflow testing can be found [in the grants repo](https://github.com/w3f/Grants-Program/blob/master/.github/workflows/README.md).
45 changes: 45 additions & 0 deletions .github/workflows/badge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Award Badge
on:
pull_request_target:
types: [closed]

jobs:
badge:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Parse delivery file
id: delivery
uses: ./.github/workflows/composite/get_delivery

- name: Get application file
if: steps.delivery.outputs.filenames
run: wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/applications/${{ steps.delivery.outputs.application-filename }}"

- name: Parse application file
id: parse-grant
if: steps.delivery.outputs.filenames
uses: w3f/parse-grant-application-action@v1
with:
path: "${{ steps.delivery.outputs.application-filename }}"

- name: Leave badge comment if applicable
if: steps.delivery.outputs.filenames && steps.delivery.outputs.milestone-number == 1 && steps.parse-grant.outputs.level != 1
uses: thollander/actions-comment-pull-request@1.0.1
with:
message: >
Congratulations on completing the first milestone of this grant!
As part of the Grants Program, we want to help grant recipients acknowledge their grants publicly.
To that end, we’ve created a [badge for projects](https://github.com/w3f/Grants-Program/blob/master/docs/grant-badge-guidelines.md)
that successfully deliver their first milestone.
Note that it must only be used within the context of the delivered work, so please do not display it on
your team or project's homepage unless accompanied by a short description of the grant.<br/><br/>
Furthermore, you're now welcome to announce the grant publicly. Please remember to observe the
[foundation’s guidelines](https://github.com/w3f/Grants-Program/blob/master/docs/announcement-guidelines.md) in doing so.
In case you haven't done so yet, you may also reach out to grantsPR@web3.foundation for feedback on your announcement and cross-promotion.<br/><br/>
Thank you for your contribution and good luck with the remaining milestones, if any!
As usual, please let us know if you run into any delays by leaving a comment on the application PR, or directly submitting an
[amendment](https://github.com/w3f/Grants-Program#changes-to-a-grant-after-approval).
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/check_author.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check Author
on:
pull_request_target:
types: [opened]

jobs:
check_author:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Parse delivery file
id: delivery
uses: ./.github/workflows/composite/get_delivery

- name: Find PR author in application authors
if: steps.delivery.outputs.filenames
uses: actions/github-script@v5
env:
pr_author: ${{ github.event.pull_request.user.login }}
with:
script: |
await github.rest.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
path: 'applications/${{ steps.delivery.outputs.application_document }}'
}).then( app_commits => {
app_authors = app_commits.data.map(c => {return c.author.login});
if(!app_authors.includes(process.env.pr_author))
core.setFailed('PR author does not match any application author.');
});
33 changes: 33 additions & 0 deletions .github/workflows/composite/get_delivery/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Parse Delivery
outputs:
filenames:
description: Filenames of all delivery documents
value: ${{ steps.files.outputs.added }}
milestone-number:
description: Milestone number
value: ${{ steps.parse-delivery.outputs.milestone_number }}
application-filename:
description: Filename of the application document
value: ${{ steps.parse-delivery.outputs.application_document }}

runs:
using: "composite"
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get filenames of any deliveries being added
id: files
uses: Ana06/get-changed-files@v2.0.0
with:
filter: 'deliveries/*.md'

- name: Parse delivery file # TODO parse all files separately if there are multiple
if: steps.files.outputs.added
id: parse-delivery
uses: w3f/parse-milestone-delivery-action@v3
with:
path: "${{ github.workspace }}/${{ steps.files.outputs.added }}"

- uses: actions/checkout@v2 # Return to master branch (otherwise the composite action fails)
110 changes: 47 additions & 63 deletions .github/workflows/google_sheet_update.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,79 @@
name: Google Sheet Update
on:
pull_request_target:
types: [opened]
types: [opened, synchronize]

jobs:
update_sheet:
get-delivery-once:
runs-on: ubuntu-latest
outputs:
has-succeeded: ${{ steps.check-no-success.outputs.has-succeeded }}
filenames: ${{ steps.delivery.outputs.filenames }}
milestone-number: ${{ steps.delivery.outputs.milestone-number }}
application-filename: ${{ steps.delivery.outputs.application-filename }}
steps:
- name: 'get names of all added files in the PR'
id: 'files'
uses: Ana06/get-changed-files@v1.2
- uses: actions/checkout@v2

- name: 'check out delivery file'
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: 'parse milestone'
id: milestone_parser
uses: w3f/parse-milestone-delivery-action@v2.13
with:
path: "${{ github.workspace }}/${{ steps.files.outputs.added }}"

- name: 'parse application doc path'
id: application_doc_path
uses: actions/github-script@0.9.0
env:
link: ${{ steps.milestone_parser.outputs.application_document }}
with:
script: |
var url_pattern = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i;
let application_doc = process.env.link.match(url_pattern);
let application_doc_path = application_doc[0];
let application_doc_path_array = application_doc_path.split('/');
application_doc_path = application_doc_path_array[application_doc_path_array.length - 2] + '/' + application_doc_path_array[application_doc_path_array.length - 1];
core.setOutput('application_doc_path', application_doc_path);
core.setOutput('application_doc_name', application_doc_path_array[application_doc_path_array.length - 1]);
- name: Parse delivery file
id: delivery
uses: ./.github/workflows/composite/get_delivery

- name: 'get application commit data'
if: ${{ success() }}
uses: octokit/request-action@v2.x
id: get_application_commit_data
- name: Check that the workflow didn't yet run successfully in this PR
uses: actions/github-script@v5
id: check-no-success
if: steps.delivery.outputs.filenames
with:
route: "GET /repos/w3f/Grants-Program/commits?path=${{ steps.application_doc_path.outputs.application_doc_path }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'find delivery author in application PRs'
uses: actions/github-script@0.9.0
id: match_author
env:
commits: ${{steps.get_application_commit_data.outputs.data}}
pr_author: ${{github.event.pull_request.user.login}}
with:
script: |
let commits = JSON.parse(process.env.commits);
for(commit of commits) {
if(commit.author.login === process.env.pr_author) {
return true;
}
}
core.setFailed(`PR author does not match any author of application.`);
// https://octokit.github.io/rest.js/v18
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'google_sheet_update.yml',
status: 'success',
per_page: 100
});
const pr_commits = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ github.event.number }},
per_page: 100
});
const runs_shas = runs.data.workflow_runs.map(run => {return run.head_sha});
const pr_shas = pr_commits.data.map(c => {return c.sha});
core.setOutput("has-succeeded", pr_shas.filter(s => runs_shas.includes(s)).length != 0);
- name: 'get application file'
run: wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/${{ steps.application_doc_path.outputs.application_doc_path }}"
update-sheet: # TODO run for each delivery if PR contains more than one (see also get_delivery.yml)
needs: get-delivery-once
if: needs.get-delivery-once.outputs.filenames && needs.get-delivery-once.outputs.has-succeeded == 'false'
runs-on: ubuntu-latest
steps:
- name: Get application file
run: wget "https://raw.githubusercontent.com/w3f/Grants-Program/master/applications/${{ needs.get-delivery-once.outputs.application-filename }}"

- name: 'parse application file'
id: grant_parser
- name: Parse application file
id: parse-grant
uses: w3f/parse-grant-application-action@v1
with:
path: "${{ steps.application_doc_path.outputs.application_doc_name }}"
path: "${{ needs.get-delivery-once.outputs.application-filename }}"

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%d/%m/%Y')"

- name: 'write the data to a gsheet'
id: 'update_worksheet'
uses: jroehl/gsheet.action@v1.1.1 # you can specify '@release' to always have the latest changes
- name: Write data to sheet
uses: jroehl/gsheet.action@v1.1.1
with:
spreadsheetId: ${{ secrets.SPREADSHEET_ID }}
commands: | # list of commands, specified as a valid JSON string. Second entry in 'data' should be project name.
commands: |
[
{
"command": "appendData",
"args":
{
"data": [[
"=IFERROR(HYPERLINK(\"#gid=0&range=\" & MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))), Legal!$D:$D, 0) & \":\" & MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))), Legal!$D:$D, 0), INDEX(Legal!$A$2:$A,MATCH(INDIRECT(CONCATENATE(\"B\", TEXT(ROW(), \"#\"))),Legal!$D$2:$D,0))), \"\")",
"${{ steps.grant_parser.outputs.project_name }}",
"${{ steps.milestone_parser.outputs.milestone_number }}",
"${{ steps.parse-grant.outputs.project_name }}",
"${{ needs.get-delivery-once.outputs.milestone_number }}",
"",
"Not Yet",
"=IFERROR(SWITCH(INDIRECT(ADDRESS(ROW(),COLUMN()-1)), \"Not Yet\", 3, \"In Progress\", 2, \"Asked for Changes\", 1, \"Final Check\", 2, \"Done\", 0, \"Terminated\", 0))",
Expand Down
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

# Created by https://www.toptal.com/developers/gitignore/api/macos,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/macos,windows
14 changes: 0 additions & 14 deletions .pr_event.json

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ The milestone delivery process is part of the [W3F Grants Program](https://githu
1. The [operations team](https://github.com/w3f/Grants-Program#team) receives a notification once the delivery is accepted. Payments are usually processed within 14 days.
2. Payment is made to the Bitcoin or Ethereum address specified in the initial application. The exchange rate for BTC depends on the time of payment.

Grant applications can be amended at any time. However, this _necessitates a reevaluation by the committee_. If your application has been accepted and, during development, you find that your project significantly deviates from the original specification, please open a new pull request that modifies the existing application.
Grant applications can be [amended](https://github.com/w3f/Grants-Program#changes-to-a-grant-after-approval) at any time. However, this _necessitates a reevaluation by the committee_. If your application has been accepted and, during development, you find that your project significantly deviates from the original specification, please open a new pull request that modifies the existing application.

## :ballot_box_with_check: External Evaluations

As part of the grant program, we allow everyone to participate in the evaluation process of submitted milestones. Successfully merged external evaluations will receive **up to 500 USD in KSM**, depending on the quality and depth of the evaluation. The payout will be sent to their Kusama identity address.
As part of the grant program, we allow everyone to participate in the evaluation process of submitted milestones. Successfully merged external evaluations will receive **up to 2 KSM**, depending on the quality and depth of the evaluation. The payout will be sent to their Kusama identity address.

### Requirements

Expand Down
Loading

0 comments on commit 5c57fe9

Please sign in to comment.