-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a5fac60
Showing
91 changed files
with
9,340 additions
and
0 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.73.0" | ||
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.73.0' }} | ||
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,41 @@ | ||
--- | ||
# yamllint disable rule:line-length | ||
name: Clear cache | ||
|
||
on: | ||
schedule: | ||
- cron: '30 1 * * 1-5' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
job1: | ||
name: Clear Docker | ||
if: always() | ||
runs-on: ${{ matrix.runner_label }} | ||
strategy: | ||
matrix: | ||
runner_label: ${{ fromJSON('["lionco-runner-1", "lionco-runner-2", "lionco-runner-3", "lionco-runner-4", "lionco-runner-5", "lionco-runner-6"]') }} | ||
steps: | ||
- name: Stop old containers | ||
run: docker ps -q | grep -q . && docker stop $(docker ps -q) -t0 || echo "No containers to stop" | ||
- name: Remove old containers | ||
run: docker ps -a -q | grep -q . && docker rm $(docker ps -a -q) || echo "No containers to remove" | ||
- name: Delete old images | ||
run: docker system prune --volumes --all --force | ||
job2: | ||
name: Clear workspaces | ||
if: always() | ||
needs: job1 | ||
runs-on: ${{ matrix.runner_label }} | ||
strategy: | ||
matrix: | ||
runner_label: ${{ fromJSON('["lionco-runner-1", "lionco-runner-2", "lionco-runner-3", "lionco-runner-4", "lionco-runner-5", "lionco-runner-6"]') }} | ||
steps: | ||
- name: Clean Workspace | ||
if: always() | ||
uses: AutoModality/[email protected] | ||
- uses: xembly/workflow-manager@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
run: clean | ||
verbose: 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
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: PR | ||
|
||
on: | ||
pull_request: | ||
types: [assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, converted_to_draft, ready_for_review, locked, unlocked, review_requested, review_request_removed] | ||
issue_comment: | ||
types: [created] | ||
pull_request_review: | ||
types: [submitted] | ||
|
||
jobs: | ||
pr_commented: | ||
# This job only runs for pull request comments | ||
name: PR comment | ||
if: ${{ github.event.issue.pull_request }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Send Notification | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ secrets.TELEGRAM_TO }} | ||
token: ${{ secrets.TELEGRAM_TOKEN }} | ||
message: | | ||
User @${{ github.actor }} commented PR #${{ github.event.issue.number }} "${{ github.event.issue.title }}" (${{ github.event.issue.pull_request.html_url }}) | ||
pull_requests_and_review: | ||
name: Pull request action or review | ||
if: ${{ !github.event.issue.pull_request }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Send Notification | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ secrets.TELEGRAM_TO }} | ||
token: ${{ secrets.TELEGRAM_TOKEN }} | ||
message: | | ||
User @${{ github.actor }} updated PR #${{ github.event.number }} "${{ github.event.pull_request.title }}", action "${{ github.event.action }}" (${{ github.event.pull_request.html_url }}) |
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,94 @@ | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
name: tests | ||
|
||
jobs: | ||
clippy: | ||
name: Actions - clippy | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: 1.73.0 | ||
components: clippy | ||
profile: minimal | ||
override: true | ||
- run: cargo fetch --verbose | ||
- run: cargo clippy --all --all-targets -- -D warnings | ||
|
||
rustfmt: | ||
name: Actions - rustfmt | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: 1.73.0 | ||
components: rustfmt | ||
profile: minimal | ||
override: true | ||
- run: cargo fmt -- --check | ||
|
||
unit-test: | ||
name: Actions - unit test | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: 1.73.0 | ||
profile: minimal | ||
- run: cargo fetch --verbose | ||
- run: cargo build | ||
- run: cargo test --verbose --all | ||
env: | ||
RUST_BACKTRACE: 1 | ||
integration-test: | ||
name: Actions - integration test | ||
runs-on: self-hosted | ||
steps: | ||
- name: Upgrade docker compose to use v2 | ||
run: sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: 1.73.0 | ||
profile: minimal | ||
override: true | ||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.16.1' | ||
cache: 'yarn' | ||
cache-dependency-path: integration_tests/yarn.lock | ||
- name: Setup Go environment | ||
uses: actions/[email protected] | ||
with: | ||
go-version: 1.20 | ||
cache: false | ||
- name: Log in to Private Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
- name: Build images | ||
run: | | ||
cd integration_tests | ||
yarn build-images | ||
- name: Lint | ||
run: cd integration_tests && yarn --ignore-engines && yarn lint | ||
- run: make compile | ||
- name: Run tests | ||
run: | | ||
cd integration_tests | ||
MAX_THREADS=4 yarn vitest ./src --run --bail 1 |
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,4 @@ | ||
.idea/ | ||
target/ | ||
**/schema/ | ||
/artifacts/ |
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,6 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
} | ||
} |
Oops, something went wrong.