Update MANIFESTO.md #569
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Runtime upgrade test | |
on: | |
issue_comment: | |
types: [created, edited] | |
jobs: | |
check-permission: | |
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/runtime-upgrade-test') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check permission | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const response = await github.rest.repos.getCollaboratorPermissionLevel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
username: context.actor | |
}); | |
const actorPermissionLevel = response.data.permission; | |
console.log(actorPermissionLevel); | |
// <- lower higher -> | |
// ["none", "read", "write", "admin"] | |
if (!(actorPermissionLevel == "admin" || actorPermissionLevel == "write")) { | |
core.setFailed("Permission denied."); | |
} | |
runtime-upgrade-test: | |
# run only when PR comments start with '/runtime-upgrade-test'. | |
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/runtime-upgrade-test') | |
needs: check-permission | |
runs-on: ubuntu-latest | |
steps: | |
- name: Validate and set inputs | |
id: test-input | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const command = `${{ github.event.comment.body }}`.split(" "); | |
console.log(command); | |
// command should be '/runtime-upgrade-test runtime' | |
if (command.length != 2) { | |
core.setFailed("Invalid input. It should be '/runtime-upgrade-test [runtime]'"); | |
} | |
const runtime = command[1]; | |
if (!['shibuya', 'shiden', 'astar'].includes(runtime)) { | |
const err = "Invalid runtime. It should be 'shibuya', 'shiden', or 'astar'."; | |
// Error message in Actions. | |
core.setFailed(err); | |
// PR comment. | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: err | |
}); | |
} | |
core.setOutput("runtime", runtime); | |
- name: Free disk space | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /opt/ghc | |
sudo rm -rf "/usr/local/share/boost" | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
df -h | |
- name: Get branch and sha | |
id: get-branch-sha | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
result-encoding: string | |
script: | | |
const pull_request = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}) | |
core.setOutput("branch", pull_request.data.head.ref) | |
core.setOutput("sha", pull_request.data.head.sha) | |
- name: Post starting comment | |
uses: actions/github-script@v7 | |
env: | |
MESSAGE: | | |
Runtime upgrade test is scheduled at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. | |
Please wait for a while. | |
Runtime: ${{ steps.test-input.outputs.runtime }} | |
Branch: ${{ steps.get-branch-sha.outputs.branch }} | |
SHA: ${{ steps.get-branch-sha.outputs.sha }} | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
result-encoding: string | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.MESSAGE | |
}) | |
- name: Checkout the source code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.get-branch-sha.outputs.sha }} | |
submodules: true | |
- name: Install deps | |
run: sudo apt -y install protobuf-compiler | |
- name: Install & display rust toolchain | |
run: rustup show | |
- name: Check targets are installed correctly | |
run: rustup target list --installed | |
- name: Build runtime | |
run: cargo build -p ${{ steps.test-input.outputs.runtime }}-runtime --release --locked | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'yarn' | |
cache-dependency-path: tests/e2e/yarn.lock | |
- name: Run runtime upgrade test | |
id: test | |
run: | | |
cd tests/e2e | |
yarn --frozen-lockfile | |
yarn test:runtime-upgrade-${{ steps.test-input.outputs.runtime }} > ${{runner.temp}}/out.txt | |
- name: Post result comment | |
uses: actions/github-script@v7 | |
env: | |
MESSAGE: | | |
Runtime upgrade test finished: | |
${{ steps.test.outputs.result }} | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
result-encoding: string | |
script: | | |
const fs = require('fs') | |
const output = fs.readFileSync('${{runner.temp}}/out.txt').toString(); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: ` | |
Runtime upgrade test finished: | |
${output.trim()} | |
` | |
}) |