Merge branch 'release/v1.0.x' into release/v1.0.x-migrate-gen #61
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: Sims | |
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short) | |
# This workflow will run on main and release branches, if a .go, .mod or .sum file have been changed | |
on: | |
push: | |
paths-ignore: | |
- 'docs/**' | |
branches: | |
- main | |
- release/** | |
tags: | |
- "*" | |
pull_request: | |
types: auto_merge_enabled | |
issue_comment: | |
types: [created, edited] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
member: | |
name: Check whether it is triggered by team members with issue_comment or push or pull_request | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
if: >- | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) || | |
github.event_name == 'push' || github.event_name == 'pull_request' | |
outputs: | |
valid: ${{ steps.setValid.outputs.valid }} | |
steps: | |
- uses: tspascoal/[email protected] | |
id: checkMember | |
if: github.event_name == 'issue_comment' | |
with: | |
username: ${{ github.actor }} | |
team: 'cronos-dev' | |
GITHUB_TOKEN: ${{ secrets.ORG_READ_BOT_PAT }} | |
- name: Comment PR for authentication failure | |
uses: crypto-org-chain/actions-pull-request-add-comment@master | |
if: (steps.checkMember.outputs.isTeamMember == 'false') && (github.event_name == 'issue_comment') | |
with: | |
message: | | |
Sorry only cronos-dev team member could run simulations by '/runsim'. | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: set valid if it is push/pull_request event or check if it is triggered by team members with issue_comment | |
id: setValid | |
run: | | |
if [[ "${{ steps.checkMember.outputs.isTeamMember }}" == "true" ]]; then | |
echo "name=valid::true" >> $GITHUB_OUTPUT | |
elif [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "pull_request" ]]; then | |
echo "name=valid::true" >> $GITHUB_OUTPUT | |
else | |
echo "name=valid::false" >> $GITHUB_OUTPUT | |
fi | |
build: | |
runs-on: ubuntu-latest | |
needs: member | |
permissions: | |
pull-requests: write | |
if: needs.member.outputs.valid == 'true' | |
outputs: | |
repo_name: ${{ steps.pr_data.outputs.repo_name }} | |
ref: ${{ steps.pr_data.outputs.ref }} | |
steps: | |
- name: Comment PR for Sim test started | |
uses: crypto-org-chain/actions-pull-request-add-comment@master | |
if: github.event_name == 'issue_comment' | |
with: | |
message: | | |
Simulation tests get triggered and started by `/runsim`. | |
Please check further progress [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Github API Request | |
id: request | |
uses: octokit/[email protected] | |
if: github.event_name == 'issue_comment' | |
with: | |
route: ${{ github.event.issue.pull_request.url }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Comment PR informations | |
id: pr_data | |
if: github.event_name == 'issue_comment' | |
run: | | |
echo "name=repo_name::${{ fromJson(steps.request.outputs.data).head.repo.full_name }}" >> $GITHUB_OUTPUT | |
comment_hash=`echo "$COMMENTBODY" | cut -d' ' -f2` # get commit hash if any | |
if [[ "${comment_hash}" == "/runsim" ]]; then | |
echo "name=ref::${{ fromJson(steps.request.outputs.data).head.ref }}" >> $GITHUB_OUTPUT # use default head ref | |
else | |
echo "name=ref::${comment_hash}" >> $GITHUB_OUTPUT # use comment provided ref | |
fi | |
- name: Checkout Comment PR Branch | |
uses: actions/checkout@v3 | |
if: github.event_name == 'issue_comment' | |
with: | |
submodules: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ steps.pr_data.outputs.repo_name }} | |
ref: ${{ steps.pr_data.outputs.ref }} | |
- name: Normal check out code | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.20.0' | |
- name: Display go version | |
run: go version | |
- run: make build | |
- name: Create file status_build.txt and write the job status into it | |
if: github.event_name == 'issue_comment' | |
run: | | |
echo ${{ job.status }} > status_build.txt | |
- name: Upload file status_build.txt as an artifact | |
if: github.event_name == 'issue_comment' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pass_status_build | |
path: status_build.txt | |
install-runsim: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.20.0' | |
- name: Display go version | |
run: go version | |
- name: Install runsim | |
run: export GO111MODULE="on" && go install github.com/cosmos/tools/cmd/[email protected] | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/bin | |
key: ${{ runner.os }}-go-runsim-binary | |
- name: Create file status_install.txt and write the job status into it | |
if: github.event_name == 'issue_comment' | |
run: | | |
echo ${{ job.status }} > status_install.txt | |
- name: Upload file status_install.txt as an artifact | |
if: github.event_name == 'issue_comment' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pass_status_install | |
path: status_install.txt | |
test-sim-nondeterminism: | |
runs-on: ubuntu-latest | |
needs: [build, install-runsim] | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.20.0' | |
- name: Checkout Comment PR Branch | |
uses: actions/checkout@v3 | |
if: github.event_name == 'issue_comment' | |
with: | |
submodules: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ needs.build.outputs.repo_name }} | |
ref: ${{ needs.build.outputs.ref }} | |
- name: Normal check out code | |
uses: actions/checkout@v3 | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
with: | |
submodules: true | |
- name: Display go version | |
run: go version | |
# the original repo technote-space does not include auto_merge_enabled into target events | |
# we can move back after this pr merged: https://github.com/technote-space/get-diff-action/pull/193 | |
- uses: adu-crypto/get-diff-action@gh-actions | |
with: | |
PATTERNS: | | |
**/**.go | |
go.mod | |
go.sum | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/bin | |
key: ${{ runner.os }}-go-runsim-binary | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: test-sim-nondeterminism | |
run: | | |
make test-sim-nondeterminism | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: Create file status_sim1.txt and write the job status into it | |
if: github.event_name == 'issue_comment' | |
run: | | |
echo ${{ job.status }} > status_sim1.txt | |
- name: Upload file status_sim1.txt as an artifact | |
if: github.event_name == 'issue_comment' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pass_status_sim1 | |
path: status_sim1.txt | |
test-sim-import-export: | |
runs-on: ubuntu-latest | |
needs: [build, install-runsim] | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.20.0' | |
- name: Checkout Comment PR Branch | |
uses: actions/checkout@v3 | |
if: github.event_name == 'issue_comment' | |
with: | |
submodules: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ needs.build.outputs.repo_name }} | |
ref: ${{ needs.build.outputs.ref }} | |
- name: Normal check out code | |
uses: actions/checkout@v3 | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
with: | |
submodules: true | |
- name: Display go version | |
run: go version | |
# the original repo technote-space does not include auto_merge_enabled into target events | |
# we can move back after this pr merged: https://github.com/technote-space/get-diff-action/pull/193 | |
- uses: adu-crypto/get-diff-action@gh-actions | |
with: | |
PATTERNS: | | |
**/**.go | |
go.mod | |
go.sum | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/bin | |
key: ${{ runner.os }}-go-runsim-binary | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: test-sim-import-export | |
run: | | |
make test-sim-import-export | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: Create file status_sim2.txt and write the job status into it | |
if: github.event_name == 'issue_comment' | |
run: | | |
echo ${{ job.status }} > status_sim2.txt | |
- name: Upload file status_sim2.txt as an artifact | |
if: github.event_name == 'issue_comment' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pass_status_sim2 | |
path: status_sim2.txt | |
test-sim-after-import: | |
runs-on: ubuntu-latest | |
needs: [build, install-runsim] | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.20.0' | |
- name: Checkout Comment PR Branch | |
uses: actions/checkout@v3 | |
if: github.event_name == 'issue_comment' | |
with: | |
submodules: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ needs.build.outputs.repo_name }} | |
ref: ${{ needs.build.outputs.ref }} | |
- name: Normal check out code | |
uses: actions/checkout@v3 | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
with: | |
submodules: true | |
- name: Display go version | |
run: go version | |
# the original repo technote-space does not include auto_merge_enabled into target events | |
# we can move back after this pr merged: https://github.com/technote-space/get-diff-action/pull/193 | |
- uses: adu-crypto/get-diff-action@gh-actions | |
with: | |
PATTERNS: | | |
**/**.go | |
go.mod | |
go.sum | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/bin | |
key: ${{ runner.os }}-go-runsim-binary | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: test-sim-after-import | |
run: | | |
make test-sim-after-import | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: Create file status_sim3.txt and write the job status into it | |
if: github.event_name == 'issue_comment' | |
run: | | |
echo ${{ job.status }} > status_sim3.txt | |
- name: Upload file status_sim3.txt as an artifact | |
if: github.event_name == 'issue_comment' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pass_status_sim3 | |
path: status_sim3.txt | |
test-sim-multi-seed-short: | |
runs-on: ubuntu-latest | |
needs: [build, install-runsim] | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.20.0' | |
- name: Checkout Comment PR Branch | |
uses: actions/checkout@v3 | |
if: github.event_name == 'issue_comment' | |
with: | |
submodules: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ needs.build.outputs.repo_name }} | |
ref: ${{ needs.build.outputs.ref }} | |
- name: Normal check out code | |
uses: actions/checkout@v3 | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
with: | |
submodules: true | |
- name: Display go version | |
run: go version | |
# the original repo technote-space does not include auto_merge_enabled into target events | |
# we can move back after this pr merged: https://github.com/technote-space/get-diff-action/pull/193 | |
- uses: adu-crypto/get-diff-action@gh-actions | |
with: | |
PATTERNS: | | |
**/**.go | |
go.mod | |
go.sum | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
- uses: actions/[email protected] | |
with: | |
path: ~/go/bin | |
key: ${{ runner.os }}-go-runsim-binary | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: test-sim-multi-seed-short | |
run: | | |
make test-sim-multi-seed-short | |
if: >- | |
(env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) || | |
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) | |
- name: Create file status_sim4.txt and write the job status into it | |
if: github.event_name == 'issue_comment' | |
run: | | |
echo ${{ job.status }} > status_sim4.txt | |
- name: Upload file status_sim4.txt as an artifact | |
if: github.event_name == 'issue_comment' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pass_status_sim4 | |
path: status_sim4.txt | |
report-status-pr: | |
runs-on: ubuntu-latest | |
needs: [member, test-sim-nondeterminism, test-sim-import-export, test-sim-after-import, test-sim-multi-seed-short] | |
permissions: | |
pull-requests: write | |
if: always() && github.event_name == 'issue_comment' && needs.member.outputs.valid == 'true' | |
steps: | |
- name: Download artifact pass_status_build | |
uses: actions/download-artifact@v1 | |
continue-on-error: true | |
with: | |
name: pass_status_build | |
- name: Download artifact pass_status_install | |
uses: actions/download-artifact@v1 | |
continue-on-error: true | |
with: | |
name: pass_status_install | |
- name: Download artifact pass_status_sim1 | |
uses: actions/download-artifact@v1 | |
continue-on-error: true | |
with: | |
name: pass_status_sim1 | |
- name: Download artifact pass_status_sim2 | |
uses: actions/download-artifact@v1 | |
continue-on-error: true | |
with: | |
name: pass_status_sim2 | |
- name: Download artifact pass_status_sim3 | |
uses: actions/download-artifact@v1 | |
continue-on-error: true | |
with: | |
name: pass_status_sim3 | |
- name: Download artifact pass_status_sim4 | |
uses: actions/download-artifact@v1 | |
continue-on-error: true | |
with: | |
name: pass_status_sim4 | |
- name: Set the statuses of Jobs as output parameters | |
id: set_outputs | |
continue-on-error: true | |
run: | | |
echo "name=status_job01::$(<pass_status_build/status_build.txt)" >> $GITHUB_OUTPUT | |
echo "name=status_job02::$(<pass_status_install/status_install.txt)" >> $GITHUB_OUTPUT | |
echo "name=status_job03::$(<pass_status_sim1/status_sim1.txt)" >> $GITHUB_OUTPUT | |
echo "name=status_job04::$(<pass_status_sim2/status_sim2.txt)" >> $GITHUB_OUTPUT | |
echo "name=status_job05::$(<pass_status_sim3/status_sim3.txt)" >> $GITHUB_OUTPUT | |
echo "name=status_job06::$(<pass_status_sim4/status_sim4.txt)" >> $GITHUB_OUTPUT | |
- name: The sim jobs has succeed | |
uses: crypto-org-chain/actions-pull-request-add-comment@master | |
if: >- | |
steps.set_outputs.outputs.status_job01 == 'success' && steps.set_outputs.outputs.status_job02 == 'success' | |
&& steps.set_outputs.outputs.status_job03 == 'success' && steps.set_outputs.outputs.status_job04 == 'success' | |
&& steps.set_outputs.outputs.status_job05 == 'success' && steps.set_outputs.outputs.status_job06 == 'success' | |
with: | |
message: | | |
✅ `/runsim` simulation test has succeeded 🎉 | |
Please further check [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: The sim jobs has failed | |
uses: crypto-org-chain/actions-pull-request-add-comment@master | |
if: >- | |
steps.set_outputs.outputs.status_job01 != 'success' || steps.set_outputs.outputs.status_job02 != 'success' | |
|| steps.set_outputs.outputs.status_job03 != 'success' || steps.set_outputs.outputs.status_job04 != 'success' | |
|| steps.set_outputs.outputs.status_job05 != 'success' || steps.set_outputs.outputs.status_job06 != 'success' | |
with: | |
message: | | |
❌ `/runsim` simulation test has failed 😅 | |
Please further check [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |