-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
132 lines (126 loc) · 4.16 KB
/
.gitlab-ci.yml
File metadata and controls
132 lines (126 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
stages:
- check
- build
- test
- rewards
lint:
stage: check
image: node:24
before_script:
- corepack enable pnpm
- pnpm install --frozen-lockfile
script:
- pnpm lint:check
- pnpm format:check
build:
stage: build
image: node:24
before_script:
- corepack enable pnpm
- pnpm install --frozen-lockfile
script:
- pnpm build
test:
stage: test
image: node:24
before_script:
- corepack enable pnpm
- pnpm install --frozen-lockfile
script:
- pnpm test:coverage
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
artifacts:
when: always
paths:
- coverage/
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
calculate-testnet-rewards:
stage: rewards
image: node:24
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $REWARD_EPOCH
- if: $CI_PIPELINE_SOURCE == "web" && $REWARD_EPOCH
before_script:
- corepack enable pnpm
- pnpm install --frozen-lockfile
- git config user.name "CI Bot"
- git config user.email "ci@flarenetwork.com"
- git remote set-url origin "https://oauth2:${GITLAB_PUSH_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"
- git fetch origin main
- git checkout main
script:
- echo "REWARD_EPOCH=${REWARD_EPOCH} UPTIME_THRESHOLD=${UPTIME_THRESHOLD:-2}"
- pnpm calculate-testnet-rewards -e "${REWARD_EPOCH}" -t "${UPTIME_THRESHOLD:-2}"
- |
if [ -n "$(git status --porcelain generated-files/)" ]; then
git add generated-files/
git commit -m "chore: coston2 rewards for epoch ${REWARD_EPOCH}"
git push origin main
else
echo "No new reward data"
fi
auto-testnet-rewards:
stage: rewards
image: node:24
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $REWARD_NETWORK == "coston2"
- if: $CI_PIPELINE_SOURCE == "web" && $REWARD_NETWORK == "coston2"
before_script:
- corepack enable pnpm
- pnpm install --frozen-lockfile
- git config user.name "CI Bot"
- git config user.email "ci@flarenetwork.com"
- git remote set-url origin "https://oauth2:${GITLAB_PUSH_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"
- git fetch origin main
- git checkout main
script:
- pnpm auto-testnet-rewards
- |
if [ -n "$(git status --porcelain 'generated-files/*/reward-epoch-*')" ]; then
EPOCH=$(git status --porcelain 'generated-files/*/reward-epoch-*' | grep -oP 'reward-epoch-\K\d+' | sort -n | tail -1 || echo "unknown")
git add 'generated-files/*/reward-epoch-*'
git commit -m "chore: coston2 rewards for epoch ${EPOCH}"
fi
- |
if [ -n "$(git status --porcelain 'generated-files/*/validator-rewards/')" ]; then
EPOCHS=$(git status --porcelain 'generated-files/*/validator-rewards/' | grep -oE 'epochs-[0-9]+-[0-9]+' | head -1 || echo "unknown")
git add 'generated-files/*/validator-rewards/'
git commit -m "chore: coston2 payout ${EPOCHS}"
fi
- git pull --rebase origin main
- git diff --quiet origin/main || git push origin main
prepare-initial-data:
stage: rewards
image: node:24
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $REWARD_NETWORK == "flare"
- if: $CI_PIPELINE_SOURCE == "web" && $REWARD_NETWORK == "flare"
before_script:
- corepack enable pnpm
- pnpm install --frozen-lockfile
- git config user.name "CI Bot"
- git config user.email "ci@flarenetwork.com"
- git remote set-url origin "https://oauth2:${GITLAB_PUSH_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git"
- git fetch origin main
- git checkout main
script:
- EPOCH=$(node scripts/get-current-reward-epoch.js)
- echo "Reward epoch ${EPOCH}"
- |
if [ -f "generated-files/reward-epoch-${EPOCH}/initial-nodes-data.json" ]; then
echo "Epoch ${EPOCH} already processed, skipping"
exit 0
fi
- pnpm prepare-initial-data -e "${EPOCH}"
- |
if [ -n "$(git status --porcelain generated-files/)" ]; then
git add generated-files/
git commit -m "chore: initial rewards data for epoch ${EPOCH}"
git pull --rebase origin main
git push origin main
else
echo "No new initial data"
fi