-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/update-docs
- Loading branch information
Showing
121 changed files
with
4,206 additions
and
747 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
--- | ||
name: Build Contracts | ||
|
||
on: | ||
schedule: | ||
- cron: '0 5 * * 1-5' | ||
push: | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
inputs: | ||
toolchain: | ||
description: 'Default Rust Toolchain' | ||
default: "1.68.2" | ||
required: true | ||
type: string | ||
target: | ||
description: 'Default Rust Target' | ||
default: "wasm32-unknown-unknown" | ||
required: true | ||
type: string | ||
branch: | ||
description: 'Default Branch or Commit hash to use' | ||
default: "main" | ||
required: true | ||
type: string | ||
id: | ||
description: 'Workflow ID (Optional)' | ||
default: "scheduled" | ||
required: false | ||
type: string | ||
|
||
env: | ||
TOOLCHAIN: ${{ inputs.toolchain || '1.68.2' }} | ||
TARGET: ${{ inputs.target || 'wasm32-unknown-unknown' }} | ||
REF: ${{ github.event_name == 'push' && github.ref || inputs.branch || 'main' }} | ||
ID: ${{ inputs.id || 'scheduled' }} | ||
|
||
jobs: | ||
build: | ||
name: Build & Upload contracts | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ env.REF }} | ||
fetch-depth: 0 | ||
- name: Save SHA | ||
run: echo "sha=$(/usr/bin/git log -1 --format='%H')" >> $GITHUB_ENV | ||
- name: Check input type | ||
run: | | ||
if git show-ref --quiet --heads $REF; then | ||
echo "REF is a branch" | ||
echo "The value is $REF" | ||
echo "REF_TYPE=branch" >> $GITHUB_ENV | ||
BRANCH_NAME="${REF#refs/heads/}" | ||
echo "BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV | ||
else | ||
echo "REF is a commit hash" | ||
echo "The value is $REF" | ||
echo "REF_TYPE=commit" >> $GITHUB_ENV | ||
fi | ||
env: | ||
REF: ${{ env.REF }} | ||
- name: Get branch name from commit | ||
if: ${{ env.REF_TYPE == 'commit' }} | ||
run: | | ||
set -x | ||
echo "REF = ${REF}" | ||
git show -s --pretty=%d "${REF}" | ||
BRANCH_NAME="$(git show -s --pretty=%d "${REF}" | sed -n 's/^.*[(,]\s*origin\/\([^),]*\).*$/\1/p')" | ||
echo "BRANCH_NAME = ${BRANCH_NAME}" | ||
echo "BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV | ||
echo "Commit ${REF} is on branch ${BRANCH_NAME}" | ||
env: | ||
REF: ${{ env.REF }} | ||
- id: 'auth' | ||
name: 'Authenticate to Google Cloud' | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
- name: 'Set up Cloud SDK' | ||
uses: 'google-github-actions/setup-gcloud@v1' | ||
- name: Evaluate Artifacts in GCP | ||
run: | | ||
if gsutil -q stat gs://neutron-contracts/${{ github.repository }}/${{ env.sha }}/*.wasm; then | ||
if [ ${{ env.ID }} != 'scheduled' ]; then | ||
echo "Force Contract Building requested, continuing workflow" | ||
echo "ARTIFACTS_EXIST=false" >> $GITHUB_ENV | ||
else | ||
echo "Directory already exists, stopping workflow" | ||
echo "ARTIFACTS_EXIST=true" >> $GITHUB_ENV | ||
fi | ||
else | ||
echo "Directory does not exist, continuing workflow" | ||
echo "ARTIFACTS_EXIST=false" >> $GITHUB_ENV | ||
fi | ||
- name: Skip Workflow if Artifacts exist | ||
if: ${{ env.ARTIFACTS_EXIST == 'true' }} | ||
run: echo "::notice::Artifacts already exist in GCP Bucket, skipping workflow." | ||
- uses: dtolnay/rust-toolchain@master | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
with: | ||
toolchain: ${{ env.TOOLCHAIN }} | ||
target: ${{ env.TARGET}} | ||
components: rustfmt, clippy | ||
- run: make schema | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
- run: cargo fetch --verbose | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
- run: cargo clippy --all --all-targets -- -D warnings | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
- run: cargo test --verbose --all | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
env: | ||
RUST_BACKTRACE: 1 | ||
- run: cargo fmt -- --check | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
- run: make compile | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
- run: make -j$(nproc) check_contracts | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
- name: 'Upload Contracts to the Cloud (repo/branch/sha)' | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
run: 'gsutil -h "Cache-Control:no-cache, no-store, must-revalidate" cp -r artifacts/* gs://neutron-contracts/${{ github.repository }}/${{ env.BRANCH }}/${{ env.sha }}/' | ||
- name: 'Set Metadata (repo/branch/sha)' | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
run: 'gsutil setmeta -r -h "x-goog-meta-Neutron-Repo: ${{ github.repository }}" -h "x-goog-meta-Neutron-Commit: ${{ env.sha }}" gs://neutron-contracts/${{ github.repository }}/${{ env.BRANCH }}/${{ env.sha }}/' | ||
- name: 'Upload Contracts to the Cloud (repo/branch/WF/ID)' | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
run: 'gsutil -h "Cache-Control:no-cache, no-store, must-revalidate" cp -r artifacts/* gs://neutron-contracts/${{ github.repository }}/${{ env.BRANCH }}/WF/${{ env.ID }}/' | ||
- name: 'Set Metadata (repo/branch/WF/ID)' | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
run: 'gsutil setmeta -r -h "x-goog-meta-Neutron-Repo: ${{ github.repository }}" -h "x-goog-meta-Neutron-Commit: ${{ env.sha }}" gs://neutron-contracts/${{ github.repository }}/${{ env.BRANCH }}/WF/${{ env.ID }}/' | ||
- name: 'Upload Contracts to the Cloud (repo/sha)' | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
run: 'gsutil -h "Cache-Control:no-cache, no-store, must-revalidate" cp -r artifacts/* gs://neutron-contracts/${{ github.repository }}/${{ env.sha }}/' | ||
- name: 'Set Metadata (repo/sha)' | ||
if: ${{ env.ARTIFACTS_EXIST == 'false' }} | ||
run: 'gsutil setmeta -r -h "x-goog-meta-Neutron-Repo: ${{ github.repository }}" -h "x-goog-meta-Neutron-Commit: ${{ env.sha }}" gs://neutron-contracts/${{ github.repository }}/${{ env.sha }}/' | ||
- name: 'Cleanup' | ||
if: always() | ||
uses: AutoModality/[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Delete old workflow runs | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
days: | ||
description: 'Number of days.' | ||
required: true | ||
default: 30 | ||
minimum_runs: | ||
description: 'The minimum runs to keep for each workflow.' | ||
required: true | ||
default: 6 | ||
delete_workflow_pattern: | ||
description: 'The name or filename of the workflow. if not set then it will target all workflows.' | ||
required: false | ||
delete_workflow_by_state_pattern: | ||
description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually' | ||
required: true | ||
default: "All" | ||
type: choice | ||
options: | ||
- "All" | ||
- active | ||
- deleted | ||
- disabled_inactivity | ||
- disabled_manually | ||
delete_run_by_conclusion_pattern: | ||
description: 'Remove workflow by conclusion: action_required, cancelled, failure, skipped, success' | ||
required: true | ||
default: "All" | ||
type: choice | ||
options: | ||
- "All" | ||
- action_required | ||
- cancelled | ||
- failure | ||
- skipped | ||
- success | ||
dry_run: | ||
description: 'Only log actions, do not perform any delete operations.' | ||
required: false | ||
|
||
jobs: | ||
del_runs: | ||
runs-on: self-hosted | ||
steps: | ||
- name: Delete workflow runs | ||
uses: Mattraks/delete-workflow-runs@v2 | ||
with: | ||
token: ${{ github.token }} | ||
repository: ${{ github.repository }} | ||
retain_days: ${{ github.event.inputs.days }} | ||
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} | ||
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }} | ||
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }} | ||
delete_run_by_conclusion_pattern: ${{ github.event.inputs.delete_run_by_conclusion_pattern }} | ||
dry_run: ${{ github.event.inputs.dry_run }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
name: Dispatch Workflow | ||
|
||
concurrency: neutron-tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
dispatch: | ||
name: Dispatch Tests Workflow | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Evaluate PR Merged Status and Labels | ||
run: | | ||
PR_MERGED=${{ github.event.pull_request.merged }} | ||
CONTAINS_LABEL=${{ contains(github.event.pull_request.labels.*.name, 'trigger-tests') }} | ||
echo "PR Merged Status: $PR_MERGED" | ||
echo "Contains 'trigger-tests' label: $CONTAINS_LABEL" | ||
if [[ "$PR_MERGED" == "true" && "$CONTAINS_LABEL" == "true" ]]; then | ||
echo "CONTINUE=true" >> $GITHUB_ENV | ||
else | ||
echo "CONTINUE=false" >> $GITHUB_ENV | ||
fi | ||
- name: Repository Dispatch | ||
if: ${{ env.CONTINUE == 'true' }} | ||
uses: peter-evans/repository-dispatch@v2 | ||
with: | ||
token: ${{ secrets.PAT_TOKEN }} | ||
repository: neutron-org/neutron-tests | ||
event-type: run-tests | ||
client_payload: '{"checkdev":"true"}' |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea/ | ||
target/ | ||
artifacts/ |
Oops, something went wrong.