Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop authored Aug 24, 2023
0 parents commit 109142b
Show file tree
Hide file tree
Showing 133 changed files with 23,346 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "cz-conventional-changelog"
}
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.sol]
indent_size = 4
31 changes: 31 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GENERAL

## The network used for testing purposes
NETWORK_NAME="mainnet" # ["mainnet", "goerli", "polygon", "polygonMumbai"]

# CONTRACTS

## Hex encoded private keys separated by a comma `,`a
PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Default hardhat account 0 private key. DON'T USE FOR DEPLOYMENTS

## Infura credentials
INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

## Gas Reporting
REPORT_GAS='true'
COINMARKETCAP_API_KEY="zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"

## Block explorers
ETHERSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASESCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# SUBGRAPH

## The Graph credentials
GRAPH_KEY="zzzzzzzzzzzz"

## Subgraph
SUBGRAPH_NAME="osx"
SUBGRAPH_VERSION="alice-debug-1s"
SUBGRAPH_NETWORK_NAME="goerli" # ["mainnet", "goerli", "polygon", "polygonMumbai"]
14 changes: 14 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# These labels (common, client, ipfs and client-common) are only informative.
# While the labels <pkg-name>-release are for trriggering the release process.

js-client:
- ./packages/js-client/**/*
- ./packages/js-client/*

subgraph:
- ./packages/subgraph/**/*
- ./packages/subgraph/*

contracts:
- ./packages/contracts/**/*
- ./packages/contracts/*
59 changes: 59 additions & 0 deletions .github/scripts/js-client-generate-release-matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import json
import os

#
# // PULL_LABELS = toJson(github.event.pull_request.labels)
#
# [
# {
# "color": "FFFFF7",
# "default": false,
# "description": "Issue describes change in the development process",
# "id": 1786730933,
# "name": "label_pqr-xyz-release",
# "node_id": "MDU6TGFiZWwxNzg2NzMwOTMz",
# "url": "https://api.github.com/repos/parzh/parzh.github.io/labels/Domain:%20dev"
# },
# {
# "color": "cc062a",
# "default": false,
# "description": "Issue must be addressed right now",
# "id": 1786706637,
# "name": "label_abc-release",
# "node_id": "MDU6TGFiZWwxNzg2NzA2NjM3",
# "url": "https://api.github.com/repos/parzh/parzh.github.io/labels/Priority:%20top"
# },
# {
# "color": "00727C",
# "default": false,
# "description": "Issue describes lack of a functionality or an open possibility of enhancement",
# "id": 1786726751,
# "name": "label_123-improvement",
# "node_id": "MDU6TGFiZWwxNzg2NzI2NzUx",
# "url": "https://api.github.com/repos/parzh/parzh.github.io/labels/Type:%20improvement"
# }
# ]
#
# Test:
# PULL_LABELS=$(cat labels.json) python3 js-clientt-generate-release-matrix.py
#

try:
labels = json.loads(os.getenv('PULL_LABELS'))
except:
labels = []

trigger_substring = "-release"
matrix = []
hasLabels = False
for label in labels:
label_name = str(label['name'])
trigger_substring_index = label_name.find(trigger_substring)
if trigger_substring_index != -1:
matrix.append({
'package': label_name[:trigger_substring_index],
})
hasLabels = True
# print("hasLabels=" + str(hasLabels) + " >> $GITHUB_OUTPUT")
# print("matrix=" + json.dumps({'include': matrix}) + " >> $GITHUB_OUTPUT")
print(json.dumps({'include': matrix}))
26 changes: 26 additions & 0 deletions .github/scripts/js-client-generate-release-notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys

changelog = sys.argv[1]

releaseNotesLines = []
with open(changelog, 'r') as f:
lines = f.readlines()
foundStart = False
i = 0
while i < len(lines):
line = lines[i]
if foundStart:
if line.startswith('## ['):
break
releaseNotesLines.append(line.strip())
if line.startswith("<!--\n"): # Skip the token line
i += 3
continue
if line.startswith('## [UPCOMING]'):
foundStart = True
i += 1

releaseNotesMsg=' \n'.join(releaseNotesLines)

with open("release-notes.txt", "w") as f:
f.write(releaseNotesMsg)
43 changes: 43 additions & 0 deletions .github/workflows/contracts-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'contracts'

env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
working-directory: packages/contracts

on:
workflow_dispatch:
push:
paths:
- 'packages/contracts/**'
- '.github/workflows/contracts-*.yml'

jobs:
tests:
runs-on: 'ubuntu-latest'
defaults:
run:
working-directory: ${{env.working-directory}}
steps:
- name: 'Check out the repo'
uses: 'actions/checkout@v3'

- name: 'Install Node.js'
uses: 'actions/setup-node@v3'
with:
cache: 'yarn'
node-version: 16

- name: 'Install the dependencies'
run: 'yarn install'

- name: 'Lint the code'
run: 'yarn lint'
working-directory: packages/contracts

- name: 'Build the contracts'
run: 'yarn build'
working-directory: packages/contracts

- name: 'Test the contracts and generate the coverage report'
run: 'yarn coverage'
working-directory: packages/contracts
31 changes: 31 additions & 0 deletions .github/workflows/formatting-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'formatting'

env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
working-directory: .

on:
workflow_dispatch:
push:

jobs:
checks:
runs-on: 'ubuntu-latest'
defaults:
run:
working-directory: ${{env.working-directory}}
steps:
- name: 'Check out the repo'
uses: 'actions/checkout@v3'

- name: 'Install Node.js'
uses: 'actions/setup-node@v3'
with:
cache: 'yarn'
node-version: 16

- name: 'Install the dependencies'
run: 'yarn install'

- name: 'Check code formatting'
run: yarn prettier:check
90 changes: 90 additions & 0 deletions .github/workflows/js-client-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: 02-JS-Publish

on:
push:
tags:
- '*'
paths:
- 'packages/js-client/**'
- '.github/workflows/js-client-*.yml'

jobs:
check_tag:
runs-on: ubuntu-latest
outputs:
package: ${{ steps.tag-info.outputs.package }}
version: ${{ steps.tag-info.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get package and version from Github Tag
id: tag-info
run: |
GITHUB_REF="${{ github.ref }}"
TAG=${GITHUB_REF##*/}
VERSION=$(echo "$TAG" | grep -woP "([0-9]+\.[0-9]+\.[0-9]+)-\w+" | sed 's/-javascript//')
PACKAGE=$(echo "$TAG" | grep -oP "javascript-(.+)" | sed 's/javascript-//')
if [ -d "./packages/$PACKAGE" ]; then
echo "package=$PACKAGE" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
test:
uses: ./.github/workflows/javascript_test.yml
secrets:
IPFS_API_KEY: ${{ secrets.IPFS_API_KEY }}
with:
run: true

publish:
runs-on: ubuntu-latest
needs: [check_tag, test]
if: ${{ needs.check_tag.outputs.package }}
steps:
- name: Validate values (package and version) from Github Tag
run: |
if [ -z "${{ needs.check_tag.outputs.package }}" ]; then
echo "::error ::No package found in tag"
exit 1
fi
if [ -z "${{ needs.check_tag.outputs.version }}" ]; then
echo "::error ::No version found in tag"
exit 1
fi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: 'develop'
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16.x
registry-url: https://registry.npmjs.org
- name: Install deps
run: yarn install --frozen-lockfile
- name: Build subpackages
run: yarn run build
- name: Publish NPM pkg (${{ needs.check_tag.outputs.package }} - ${{ needs.check_tag.outputs.version }})
run: yarn publish --no-git-tag-version --new-version ${{ needs.check_tag.outputs.version }}
working-directory: ./packages/${{ needs.check_tag.outputs.package }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Setup Python environment
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Generate release-notes.txt
id: notes
run: python ./.github/scripts/js-client-generate-release-notes.py "./packages/${{ needs.check_tag.outputs.package }}/CHANGELOG.md"
- name: Add NPM pkg info to release-notes.txt
run: |
echo "### NPM Packages" >> release-notes.txt
echo "- [@aragon/sdk-${{ needs.check_tag.outputs.package }} version ${{ needs.check_tag.outputs.version }}](https://www.npmjs.com/package/@aragon/sdk-${{ needs.check_tag.outputs.package }})" >> release-notes.txt
echo " " >> release-notes.txt
- name: Create a Github Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: false
body_path: release-notes.txt
75 changes: 75 additions & 0 deletions .github/workflows/js-client-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: 01-JS-Release

on:
pull_request:
types:
- closed
paths:
- 'packages/js-client/**'
- '.github/workflows/js-client-*.yml'

jobs:
test:
uses: ./.github/workflows/javascript_test.yml
secrets:
IPFS_API_KEY: ${{ secrets.IPFS_API_KEY }}

prepare:
name: Prepare release generation
needs: ['test']
runs-on: ubuntu-latest
if: github.event.pull_request.merged
outputs:
PACKAGE_LIST: ${{ steps.matrix.outputs.pkg_list }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: 'develop'
- name: Setup Python environment
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Get package-list from label-list
id: matrix
run: |
PKG_LIST=$(python ./.github/scripts/js-client-generate-release-matrix.py)
PR_LABEL_LIST="${{ toJson(github.event.pull_request.labels.*.name) }}"
echo "Pkg list: $PKG_LIST"
echo "Label list: $PR_LABEL_LIST"
echo "pkg_list=$PKG_LIST" >> $GITHUB_OUTPUT
env:
PULL_LABELS: ${{ toJson(github.event.pull_request.labels) }}

release:
name: Set Github Tag
runs-on: ubuntu-latest
needs: [prepare]
## This condition gets TRUE if used in this way: ${{ contains(toJson(xyz), 'substr') }}
if: ${{ contains( toJson(github.event.pull_request.labels.*.name), '-release' ) }}
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.prepare.outputs.PACKAGE_LIST) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: 'develop'
- name: Get version from '${{ matrix.package }}' package.json
id: getver
working-directory: './packages/${{ matrix.package }}'
run: |
VERSION=$(cat package.json | jq -r .version)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Set Github Tag via API
uses: actions/github-script@v6
with:
github-token: ${{ secrets.ARABOT_PAT_TRIGGER_WORKFLOW }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${{ steps.getver.outputs.version }}-javascript-${{ matrix.package }}`,
sha: "${{ github.sha }}"
})
Loading

0 comments on commit 109142b

Please sign in to comment.