Skip to content

Commit

Permalink
ci(PR): manage validator checks in PR.yml (#3767)
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop authored Mar 20, 2024
1 parent e0b07cd commit 7c32cf7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/actions/message/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ outputs:
description: If enable native Windows build.
macos:
description: If enable macOS build.
validator:
description: If enable validator checks.
release:
description: If enable release build.

Expand Down
4 changes: 4 additions & 0 deletions .github/actions/message/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const WINDOWS_NATIVE = "E1-forcenatwin";
const MACOS = "E2-forcemacos";
const RELEASE = "E3-forcerelease";
const SKIP_CI = "[skip-ci]";
const VALIDATOR_LABEL = "check-validator";
const [owner, repo] = ["gear-tech", "gear"];

/**
Expand Down Expand Up @@ -75,6 +76,7 @@ async function main() {
const build =
!skipCI &&
(isDepbot || BUILD_LABELS.some((label) => labels.includes(label)));
const validator = !skipCI && labels.includes(VALIDATOR_LABEL);
const win_native = !skipCI && labels.includes(WINDOWS_NATIVE);
const macos = !skipCI && labels.includes(MACOS);
const release = !skipCI && labels.includes(RELEASE);
Expand All @@ -85,12 +87,14 @@ async function main() {
core.setOutput("win-native", win_native);
core.setOutput("macos", macos);
core.setOutput("release", release);
core.setOutput("validator", !skipCI);

console.log("---");
console.log("build: ", build);
console.log("check: ", !skipCI);
console.log("native windows: ", win_native);
console.log("macos: ", macos);
console.log("validator: ", validator);
console.log("release: ", release);

// Mock checks if skipping CI.
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
check: ${{ steps.config.outputs.check }}
win-native: ${{ steps.config.outputs.win-native }}
macos: ${{ steps.config.outputs.macos }}
validator: ${{ steps.config.outputs.validator }}
release: ${{ steps.config.outputs.release }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -68,3 +69,12 @@ jobs:
macos: ${{ needs.status.outputs.macos == 'true' }}
win-native: ${{ needs.status.outputs.win-native == 'true' }}
release: ${{ needs.status.outputs.release == 'true' }}

validator:
needs: status
if: ${{ needs.status.outputs.validator == 'true' }}
uses: ./.github/workflows/validation.yml
secrets:
VARA_VALIDATOR_8: ${{ secrets.VARA_VALIDATOR_8 }}
SSH_VARA_USERNAME: ${{ secrets.SSH_VARA_USERNAME }}
VARA_SSH_PRIVATE_KEY: ${{ secrets.VARA_SSH_PRIVATE_KEY }}
16 changes: 9 additions & 7 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Live check on Vara Network Validator machine

on:
pull_request:
types: [synchronize, labeled, opened, reopened, ready_for_review]
branches: [master]
workflow_dispatch:
workflow_call:
secrets:
VARA_VALIDATOR_8:
required: true
SSH_VARA_USERNAME:
required: true
VARA_SSH_PRIVATE_KEY:
required: true

env:
CARGO_TERM_COLOR: always

jobs:
tag-image:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'check-validator')
outputs:
image_tag: ${{ steps.image-tag.outputs.tag }}
steps:
Expand All @@ -25,10 +29,8 @@ jobs:

build-update-validator:
runs-on: [kuberunner]
if: contains(github.event.pull_request.labels.*.name, 'check-validator')
needs: tag-image
steps:

- name: Checkout repo
uses: actions/checkout@v4

Expand Down Expand Up @@ -56,7 +58,7 @@ jobs:

- name: SSH into VM
uses: appleboy/ssh-action@v1.0.3
env:
env:
NEW_IMAGE: ${{ needs.tag-image.outputs.image_tag }}
with:
host: ${{ secrets.VARA_VALIDATOR_8 }}
Expand Down

0 comments on commit 7c32cf7

Please sign in to comment.