Skip to content

Commit

Permalink
Added CI environment and github action
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasia committed Jun 16, 2024
1 parent cee13c9 commit a8a93c5
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Run all jobs in ci-check-env.yml. Pass in an .env file as Environment variables
act -W .github/workflows/ci-check-env.yml --var-file packages/contracts/.env --secret-file packages/contracts/.secret --container-architecture linux/amd64
```

### Run Contracts jobs
Runs the api job - only the Env should be an .env (configs are in .toml) - local secrets are in .env
```bash
act -W .github/workflows/ci-dev-contracts.yml --var ENVIRONMENT=local --secret-file packages/contracts/.env --container-architecture linux/amd64
```

### Run API jobs
Runs the api job - only the Env should be an .env (configs are in .toml) - local secrets are in .env
```bash
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/ci-dev-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ jobs:
- uses: actions/checkout@v4

- name: Install yarn
run: npm install -g yarn
run: |
corepack prepare yarn@stable --activate
npm install -g yarn
- uses: actions/setup-node@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/ci-dev-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
- name: Install yarn
run: |
corepack prepare yarn@stable --activate
npm install -g yarn
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/ci-dev-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,32 @@ jobs:
env:
ENVIRONMENT: local

- uses: actions/setup-node@v4
- name: Install yarn
run: |
corepack prepare yarn@stable --activate
npm install -g yarn
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"

- name: Install dependencies
run: yarn install

- name: Deploy contracts
- name: Deploy contracts and export to Test supabase
run: yarn deploy:ci
env:
ENVIRONMENT: ${{ vars.ENVIRONMENT }}
ENVIRONMENT: "testnet"
DEPLOYER_PRIVATE_KEY: ${{ secrets.BASE_SEPOLIA_DEPLOYER_PRIVATE_KEY }}
BASE_SEPOLIA_ETHERSCAN_API_KEY: ${{ secrets.BASE_SEPOLIA_ETHERSCAN_API_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.TEST_SUPABASE_SERVICE_ROLE_KEY }}

- name: Deploy contracts and export to CI supabase
run: yarn deploy:ci
env:
ENVIRONMENT: "ci"
DEPLOYER_PRIVATE_KEY: ${{ secrets.BASE_SEPOLIA_DEPLOYER_PRIVATE_KEY }}
BASE_SEPOLIA_ETHERSCAN_API_KEY: ${{ secrets.BASE_SEPOLIA_ETHERSCAN_API_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.CI_SUPABASE_SERVICE_ROLE_KEY }}
14 changes: 7 additions & 7 deletions packages/api/resource/api-ci.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
##
# The Application Configuration for the TestNet Environment.
# The Application Configuration for the CI Environment.
##

node_env = "development"
node_env = "ci"

[api]
#TODO - confirm port
port = 3001
version = "0.0.1"

Expand All @@ -16,9 +15,10 @@ block_history = 1000
url = "https://iucsqvvjujqcncowypnr.supabase.co"

[services.ethers]
url = "http://127.0.0.1:8545"
wss = "ws://127.0.0.1:8545"
# settings for baseSepolia, see others: https://chainlist.org/
url = "https://sepolia.base.org"
wss = "https://sepolia.base.org"

[evm.address]
# Dev/Anvil Wallet, Account[1]
operator = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
# devops operator (wallet 2) - public address, okay to share
operator = "0xaD3C004eE1f942BFDA2DA0D2DAaC94d6aC012F75"
1 change: 0 additions & 1 deletion packages/api/resource/api-testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
node_env = "testnet"

[api]
#TODO - confirm port
port = 3001
version = "0.0.1"

Expand Down
34 changes: 34 additions & 0 deletions packages/contracts/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# fly.toml app configuration file generated for credbull-defi-api on 2024-02-06T11:47:45-03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'credbull-defi-contracts'

primary_region = 'fra'

[build]
image = "credbull-defi-contracts:latest"

[deploy]
strategy = "bluegreen"

[http_service]
internal_port = 8545
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[http_service.checks]]
grace_period = "10s"
interval = "30s"
method = "GET"
timeout = "5s"
path = "/"

[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 1024
24 changes: 24 additions & 0 deletions packages/contracts/resource/ci.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
##
# The Application Configuration for the TestNet Environment.
##

[evm]
# blockchain id, e.g. baseSepolia=84532, arbSepolia=421614
chain_id = 84532

[evm.address]
# credbull-devops wallets. wallet numbers are 1-based (as opposed to 0-based in anvil)
# devops admin/owner (wallet 1) - public address, okay to share
owner = "0xD79Be36f61fce3B8EF2FBF22b13B2b9a68eE15A2"
# devops operator (wallet 2) - public address, okay to share
operator = "0xaD3C004eE1f942BFDA2DA0D2DAaC94d6aC012F75"

[evm.contracts.upside_vault]
# 2 decimal place percentage (meaining value divided by 100) as integer.
collateral_percentage = 200

[services.supabase]
url = "https://iucsqvvjujqcncowypnr.supabase.co"

# Export contract details to supabase.
export_contracts = true
2 changes: 1 addition & 1 deletion packages/contracts/script/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const loadConfiguration = (): Config => {
const toml = fs.readFileSync(configFile, 'utf8');
const config: Config = load(toml);

console.log(`Successfully loaded configuration from: '${configFile}'`);
console.log('Successfully loaded configuration:', JSON.stringify(config, null, 2));

// include Environment into config
// NB - call this after the log statement to avoid logging keys!
Expand Down

0 comments on commit a8a93c5

Please sign in to comment.