Skip to content

Commit eb7c13a

Browse files
committed
Add GitHub workflows
1 parent f195d50 commit eb7c13a

File tree

10 files changed

+2658
-67
lines changed

10 files changed

+2658
-67
lines changed

.eslintrc.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
"node": true,
66
"jest": true
77
},
8-
"extends": [
9-
"react-app",
10-
"react-app/jest",
11-
"prettier"
12-
],
8+
"extends": ["react-app", "prettier"],
139
"plugins": ["prettier"],
1410
"rules": {
1511
"prettier/prettier": "error",

.github/workflows/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @lukaw3d @buberdds @csillag @lubej @ptrus

.github/workflows/ci-build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: ci-build
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched branches.
7+
push:
8+
branches:
9+
- master
10+
- stable/*
11+
# Or when a pull request event occurs for a pull request against one of the
12+
# matched branches.
13+
pull_request:
14+
branches:
15+
- master
16+
- stable/*
17+
18+
jobs:
19+
build:
20+
# NOTE: This name appears in GitHub's Checks API.
21+
name: build
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
with:
27+
submodules: true
28+
- name: Set up Node.js 20
29+
uses: actions/setup-node@v6
30+
with:
31+
node-version: "20.x"
32+
cache: yarn
33+
- name: Install dependencies
34+
run: yarn install --frozen-lockfile
35+
- name: Set workflow variables
36+
# Id is needed to access output in a next step.
37+
id: vars
38+
run: |
39+
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
40+
- name: Build app
41+
run: yarn build
42+
- name: Upload build artifacts
43+
# Upload build artifacts on push event.
44+
if: github.event_name == 'push'
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: csv-exporter-${{ steps.vars.outputs.SHORT_SHA }}
48+
path: dist

.github/workflows/ci-lint.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: ci-lint
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched branches.
7+
push:
8+
branches:
9+
- master
10+
- stable/*
11+
# Or when a pull request event occurs for a pull request against one of the
12+
# matched branches.
13+
pull_request:
14+
branches:
15+
- master
16+
- stable/*
17+
18+
jobs:
19+
lint:
20+
# NOTE: This name appears in GitHub's Checks API.
21+
name: lint
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
with:
27+
submodules: true
28+
# Checkout pull request HEAD commit instead of merge commit.
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
# Fetch all history so gitlint can check the relevant commits.
31+
fetch-depth: "0"
32+
- name: Set up Python 3
33+
uses: actions/setup-python@v6
34+
with:
35+
python-version: "3.x"
36+
- name: Set up Node.js 20
37+
uses: actions/setup-node@v6
38+
with:
39+
node-version: "20.x"
40+
cache: yarn
41+
- name: Install dependencies
42+
run: yarn install --frozen-lockfile
43+
- name: Install gitlint
44+
run: |
45+
python -m pip install gitlint
46+
# Needed for Towncrier fork to work with 3.12 and above
47+
- name: Install setuptools
48+
run: |
49+
python -m pip install setuptools
50+
- name: Install towncrier
51+
run: |
52+
python -m pip install https://github.com/oasisprotocol/towncrier/archive/oasis-master.tar.gz
53+
- name: Check for presence of a Change Log fragment (only pull requests)
54+
# NOTE: The pull request' base branch needs to be fetched so towncrier
55+
# is able to compare the current branch with the base branch.
56+
# Source: https://github.com/actions/checkout/#fetch-all-branches.
57+
run: |
58+
git fetch --no-tags origin "+refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}"
59+
towncrier check --compare-with "origin/${BASE_BRANCH}"
60+
env:
61+
BASE_BRANCH: ${{ github.base_ref }}
62+
if: github.event_name == 'pull_request'
63+
- name: Lint documentation
64+
run: |
65+
yarn lint-docs
66+
# Always run this step so that all linting errors can be seen at once.
67+
if: always()
68+
- name: Lint Change Log fragments
69+
run: |
70+
yarn lint-changelog
71+
# Always run this step so that all linting errors can be seen at once.
72+
if: always()
73+
# - name: Lint git commits
74+
# run: |
75+
# yarn lint-git
76+
# Always run this step so that all linting errors can be seen at once.
77+
# if: always()
78+
- name: Prettier
79+
run: yarn prettier-check
80+
# Always run this step so that all linting errors can be seen at once.
81+
if: always()
82+
- name: ESLint
83+
# Disallow warnings and always throw errors.
84+
run: yarn lint --max-warnings 0
85+
# Always run this step so that all linting errors can be seen at once.
86+
if: always()
87+
- name: Validate TypeScript
88+
run: yarn checkTs
89+
# Always run this step so that all linting errors can be seen at once.
90+
if: always()

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
2+
name: release
3+
4+
# Trigger the workflow when:
5+
on:
6+
# A push occurs to one of the matched tags.
7+
push:
8+
tags:
9+
# Pattern that roughly matches Oasis Core's version tags.
10+
# For more details on GitHub Actions' pattern match syntax, see:
11+
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags.
12+
- "v[0-9]+.[0-9]+*"
13+
14+
jobs:
15+
release:
16+
# NOTE: This name appears in GitHub's Checks API.
17+
name: prepare-release
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
submodules: true
26+
- name: Set up Node.js 20
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "20.x"
30+
cache: yarn
31+
- name: Install dependencies
32+
run: yarn install --frozen-lockfile
33+
- name: Build app
34+
run: yarn build
35+
- name: Set workflow variables
36+
# Id is needed to access output in a next step.
37+
id: vars
38+
env:
39+
# There's no support for escaping this for use in a shell command.
40+
# GitHub's recommendation is to pass it through the environment.
41+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
42+
REF_NAME: ${{ github.ref_name }}
43+
# We want to show version without the leading 'v'
44+
# and use short SHA of the commit for file name.
45+
run: |
46+
echo "VERSION=$(echo "$REF_NAME" | sed 's/^v//')" >> "$GITHUB_OUTPUT"
47+
- name: Create zip file
48+
env:
49+
# Need to escape again
50+
VERSION: ${{ steps.vars.outputs.VERSION }}
51+
run: |
52+
cd dist/
53+
zip -r "../csv-exporter-$VERSION.zip" .
54+
- name: Parse CHANGELOG.md file and extract changes for the given version
55+
uses: buberdds/extract-changelog-action@v1
56+
id: changelog
57+
with:
58+
version: ${{ steps.vars.outputs.VERSION }}
59+
- name: Release
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
files: |
63+
csv-exporter-${{ steps.vars.outputs.VERSION }}.zip
64+
name: CSV Exporter ${{ steps.vars.outputs.VERSION }}
65+
body: ${{ steps.changelog.outputs.content }}
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Web tool to export Oasis Network accounting events and staking rewards to CSV format.
44

5-
Live: https://reports.oasis.io
5+
Live: [Preview]
66

77
## Features
88

@@ -28,3 +28,5 @@ npm run build
2828
```bash
2929
npm test
3030
```
31+
32+
[Preview]: https://reports.oasis.io

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
"lint": "eslint src/",
1515
"lint:fix": "eslint src/ --fix",
1616
"format": "prettier --write src/",
17-
"format:check": "prettier --check src/",
18-
"lint-changelog": "markdownlint --config .changelog/.markdownlint.yml .changelog/"
17+
"prettier-check": "prettier --check src/",
18+
"lint-git": "node ./internals/scripts/gitlint.cjs",
19+
"lint-docs": "markdownlint --ignore '**/node_modules/**' '**/*.md'",
20+
"lint-changelog": "markdownlint --config .changelog/.markdownlint.yml .changelog/",
21+
"checkTs": "tsc --noEmit"
1922
},
2023
"dependencies": {
2124
"axios": "^1.7.9",
@@ -44,6 +47,7 @@
4447
"autoprefixer": "^10.4.20",
4548
"eslint": "^8.57.1",
4649
"eslint-config-prettier": "^10.1.8",
50+
"eslint-config-react-app": "^7.0.1",
4751
"eslint-plugin-prettier": "^5.5.4",
4852
"jsdom": "^27.0.1",
4953
"markdownlint-cli": "^0.47.0",

src/fetchStakingRewards.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,7 @@ export const fetchStakingRewards = async (NEXUS_API, address, year, granularity,
345345
}
346346

347347
// For 2025 or incomplete years, ensure we include the current endEpoch if not already
348-
if (
349-
epochsToProcess.length === 0 ||
350-
epochsToProcess[epochsToProcess.length - 1] < endEpoch
351-
) {
348+
if (epochsToProcess.length === 0 || epochsToProcess[epochsToProcess.length - 1] < endEpoch) {
352349
epochsToProcess.push(endEpoch);
353350
}
354351
}

src/fetchStakingRewards.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe("Integration test for oasis1qpnzqwj58m48sra4uuvazpqnw0zwlqfvnvjctldl (m
123123
// The sum of all monthly rewards should equal the yearly total
124124

125125
const userShares = BigInt("138906201889790");
126-
const validator = "oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe";
126+
// const validator = "oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe";
127127

128128
// Simulated monthly history entries (epoch, active_balance, active_shares)
129129
// Showing gradual balance growth throughout 2024

0 commit comments

Comments
 (0)