Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci workflow #673

Merged
merged 19 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
name: Build Contracts & Schemas

on:
pull_request:
branches: [main, development]
workflow_dispatch:
inputs:
network:
description: "Network to deploy to"
required: true
type: string
kernel_address:
description: "Kernel address"
required: false
type: string
deploy_os:
description: "Deploy OS"
required: false
type: boolean
contracts:
description: "Contracts to deploy"
required: false
type: string

jobs:
build:
Expand Down Expand Up @@ -51,3 +67,30 @@ jobs:
name: schema
path: ./schemas/
if-no-files-found: error

trigger-deploy:
needs: [build, build-schemas]
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Trigger Deploy Workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CI_PAT }}
script: |
try {
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'deploy.yml',
ref: github.ref,
inputs: {
network: '${{ inputs.network }}',
kernel_address: '${{ inputs.kernel_address }}',
deploy_os: '${{ inputs.deploy_os }}',
contracts: '${{ inputs.contracts }}'
}
});
} catch (error) {
core.setFailed(`Failed to trigger deploy workflow: ${error.message}`);
}
111 changes: 101 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Deploy OS

on:
workflow_dispatch:
inputs:
Expand All @@ -16,7 +15,7 @@ on:
required: false
type: boolean
contracts:
description: "Contracts to deploy (e.g. splitter, validator-staking)"
description: "Contracts to deploy"
required: false
type: string

Expand All @@ -26,16 +25,45 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build Contracts
run: |
sudo make version-map
make version-map
make build
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: contracts
path: ./artifacts/
if-no-files-found: error


build_schemas:
if: contains('["crnbarr93", "SlayerAnsh", "joemonem", "DimitrijeDragasevic", "cowboy0015"]', github.actor)
runs-on: ubuntu-latest
outputs:
schema_url: ${{ steps.upload-schemas.outputs.artifact-url }}
steps:
- uses: actions/checkout@v4
- name: Build Schemas
run: |
set -eo pipefail
make schemas || {
echo "Schema build failed"
exit 1
}
- name: Upload Schemas to Temp
id: upload-schemas
uses: actions/upload-artifact@v4
with:
name: temp-schemas
path: ./schemas/
retention-days: 1
if-no-files-found: error

build_deploy_script:
if: contains('["crnbarr93", "SlayerAnsh", "joemonem", "DimitrijeDragasevic", "cowboy0015"]', github.actor)
runs-on: ubuntu-latest
Expand All @@ -49,9 +77,10 @@ jobs:
name: deploy
path: ./target/release/andromeda-deploy
if-no-files-found: error

deploy:
runs-on: ubuntu-latest
needs: [build_contracts, build_deploy_script]
needs: [build_contracts, build_schemas, build_deploy_script]
env:
DEPLOYMENT_CHAIN: ${{ inputs.network }}
DEPLOYMENT_KERNEL_ADDRESS: ${{ inputs.kernel_address }}
Expand Down Expand Up @@ -80,9 +109,71 @@ jobs:
run: |
chmod +x ./andromeda-deploy
./andromeda-deploy
- name: Upload Deployment Report
uses: actions/upload-artifact@v4
with:
name: deployment-report
path: ./deployment-reports/
if-no-files-found: error

trigger-schema-parser:
needs: [deploy, build_schemas]
runs-on: ubuntu-latest
steps:
- name: Set Branch Based on Kernel
id: check-kernel
run: |
KERNEL_ADDRESS="${{ inputs.kernel_address }}"
TESTNET_KERNELS="${{ vars.TESTNET_KERNELS }}"
TESTNET_STAGING_KERNELS="${{ vars.TESTNET_STAGING_KERNELS }}"

if [[ "${KERNEL_ADDRESS}" == "${TESTNET_KERNELS}" ]]; then
echo "branch=develop" >> $GITHUB_OUTPUT
elif [[ "${KERNEL_ADDRESS}" == "${TESTNET_STAGING_KERNELS}" ]]; then
echo "branch=testnet-staging" >> $GITHUB_OUTPUT
else
echo "Error: Kernel not found in known configurations"
exit 1
fi

- name: Checkout Schema Parser
uses: actions/checkout@v4
with:
repository: andromedaprotocol/schema-parser
ref: ${{ steps.check-kernel.outputs.branch }}
token: ${{ secrets.CI_PAT }}

- name: Download Schemas
uses: actions/download-artifact@v4
with:
name: temp-schemas
path: "packages/schema-parser/schema"

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'

- name: Process Schema
working-directory: packages/schema-parser
run: |
set -eo pipefail
echo "Installing dependencies..."
pnpm install
echo "Processing schema..."
npm run start
echo "Flattening schema..."
npm run flatten
echo "Exporting schema..."
npm run export

- name: Commit and Push Changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

if [[ -n $(git status --porcelain) ]]; then
git add .
git commit -m "chore: Update schema for kernel: ${{ inputs.kernel_address }}"
git push
else
echo "No changes to commit"
fi
crnbarr93 marked this conversation as resolved.
Show resolved Hide resolved