diff --git a/.drone.yml b/.drone.yml index b1e70250d..b86ad08e3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,331 +33,7 @@ steps: echo "ABIs not up-to-date in packages/subgraph, need to run 'npm run refresh-abis'" exit 1 fi - ---- -# deploy sharing smart contract to prod, staging or dev -kind: pipeline -type: docker -name: sharing-smart-contract deploy - -trigger: - event: - - promote - target: - # deploy and verify the AddOnlyAppWhitelistRegistry and DataProtectorSharing contracts with the dev deployer - - sharing-smart-contract-deploy-dev - # deploy and verify the AddOnlyAppWhitelistRegistry and DataProtectorSharing contracts with the dev deployer, configure DataProtectorSharing for staging and commit the staging environment update - - sharing-smart-contract-deploy-staging - # deploy and verify the AddOnlyAppWhitelistRegistry and DataProtectorSharing contracts with the prod deployer and commit the prod environment update - - sharing-smart-contract-deploy-prod - branch: - - main - -steps: - - name: install-deps - image: node:18.19 - pull: always - commands: - - cd packages/sharing-smart-contract - - node -v - - npm -v - - npm ci - - - name: install-forge - image: node:18.19 - pull: always - commands: - - export XDG_CONFIG_HOME=/drone/src - - curl -L https://foundry.paradigm.xyz | bash - - export PATH="$PATH:/drone/src/.foundry/bin" - - foundryup - - cd packages/sharing-smart-contract - - forge install foundry-rs/forge-std --no-git - - - name: bellecour-fork - detach: true - image: ghcr.io/foundry-rs/foundry:latest - pull: always - expose: - - 8545 - commands: - - anvil --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url https://bellecour.iex.ec --chain-id 134 --gas-limit 6700000 --gas-price 0 - - - name: bellecour-fork-healthy - image: bash - commands: - - while ! nc -z bellecour-fork 8545 ; do sleep 1 ; done && echo "bellecour-fork ready" - depends_on: - - bellecour-fork - - - name: compile - image: node:18.19 - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run compile - depends_on: - - install-forge - - install-deps - - - name: check format - image: node:18.19 - commands: - - cd packages/sharing-smart-contract - - npm run check-format - depends_on: - - install-deps - - - name: lint - image: node:18.19 - commands: - - cd packages/sharing-smart-contract - - npm run lint - depends_on: - - install-deps - - - name: uml-diagrams - image: node:18.19 - commands: - - cd packages/sharing-smart-contract - - npm run uml - depends_on: - - install-deps - - - name: static-analyzer - image: node:18.19 - commands: - - cd packages/sharing-smart-contract - - git clone https://github.com/Picodes/4naly3er.git - - cd 4naly3er - - git reset --hard HEAD~1 # FIX issue https://github.com/Picodes/4naly3er/issues/48 - - yarn install - - yarn analyze ../contracts - depends_on: - - compile - - lint - - - name: hardhat-tests - image: node:18.19 - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run test -- --network ci-bellecour-fork - depends_on: - - install-deps - - install-forge - - compile - - bellecour-fork-healthy - - - name: forge-tests - image: node:18.19 - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - forge test --no-match-test "invariant" -vvvvv - depends_on: - - install-deps - - install-forge - - compile - - bellecour-fork-healthy - - - name: smart-contract-dev-deployment - image: node:18.19 - environment: - WALLET_PRIVATE_KEY: - from_secret: deployer-dev-privatekey - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run deploy -- --network bellecour - depends_on: - - compile - - forge-tests - - hardhat-tests - when: - target: - - sharing-smart-contract-deploy-dev - - - name: smart-contract-staging-deployment - image: node:18.19 - environment: - WALLET_PRIVATE_KEY: - from_secret: deployer-dev-privatekey - ENV: staging - MANIFEST_DEFAULT_DIR: .openzeppelin/staging - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run deploy -- --network bellecour - - git add .openzeppelin - depends_on: - - compile - - forge-tests - - hardhat-tests - when: - target: - - sharing-smart-contract-deploy-staging - - - name: smart-contract-prod-deployment - image: node:18.19 - environment: - WALLET_PRIVATE_KEY: - from_secret: deployer-prod-privatekey - MANIFEST_DEFAULT_DIR: .openzeppelin/prod - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run deploy -- --network bellecour - - git add .openzeppelin - depends_on: - - compile - - forge-tests - - hardhat-tests - when: - target: - - sharing-smart-contract-deploy-prod - - - name: update-prod-env - image: node:18.19 - environment: - ENV: prod - commands: - - cd environments - - KEY=dataprotectorSharingContractAddress VALUE=$(cat ../packages/sharing-smart-contract/deployments/DataProtectorSharing/address) npm run update-env - - KEY=dataprotectorSharingStartBlock VALUE=$(cat ../packages/sharing-smart-contract/deployments/DataProtectorSharing/block) npm run update-env - - KEY=addOnlyAppWhitelistRegistryContractAddress VALUE=$(cat ../packages/sharing-smart-contract/deployments/AddOnlyAppWhitelistRegistry/address) npm run update-env - - KEY=addOnlyAppWhitelistRegistryStartBlock VALUE=$(cat ../packages/sharing-smart-contract/deployments/AddOnlyAppWhitelistRegistry/block) npm run update-env - - git add environments.json - - git commit -m "$DRONE_DEPLOY_TO deployment $DRONE_BUILD_NUMBER $DRONE_COMMIT" --author="drone-product " - when: - target: - - sharing-smart-contract-deploy-prod - depends_on: - - smart-contract-prod-deployment - - - name: update-staging-env - image: node:18.19 - environment: - ENV: staging - commands: - - cd environments - - KEY=dataprotectorSharingContractAddress VALUE=$(cat ../packages/sharing-smart-contract/deployments/DataProtectorSharing/address) npm run update-env - - KEY=dataprotectorSharingStartBlock VALUE=$(cat ../packages/sharing-smart-contract/deployments/DataProtectorSharing/block) npm run update-env - - KEY=addOnlyAppWhitelistRegistryContractAddress VALUE=$(cat ../packages/sharing-smart-contract/deployments/AddOnlyAppWhitelistRegistry/address) npm run update-env - - KEY=addOnlyAppWhitelistRegistryStartBlock VALUE=$(cat ../packages/sharing-smart-contract/deployments/AddOnlyAppWhitelistRegistry/block) npm run update-env - - git add environments.json - - git commit -m "$DRONE_DEPLOY_TO deployment $DRONE_BUILD_NUMBER $DRONE_COMMIT" --author="drone-product " - when: - target: - - sharing-smart-contract-deploy-staging - depends_on: - - smart-contract-staging-deployment - - - name: smart-contract-staging-update-env - image: node:18.19 - environment: - WALLET_PRIVATE_KEY: - # TODO replace by dataprotector-admin-dev-privatekey - from_secret: deployer-dev-privatekey - ENV: staging - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run update-env -- --network bellecour - depends_on: - # relies on environments.json - - update-staging-env - when: - target: - - sharing-smart-contract-deploy-staging - - - name: git-push - image: appleboy/drone-git-push - settings: - remote: ssh://git@github.com/iExecBlockchainComputing/dataprotector-sdk.git - branch: update-env-${DRONE_BUILD_NUMBER} - ssh_key: - from_secret: ssh-key-team-product-github-push - when: - target: - - sharing-smart-contract-deploy-prod - - sharing-smart-contract-deploy-staging - depends_on: - - update-prod-env - - update-staging-env - - smart-contract-staging-update-env - ---- -# pipeline to updateEnv in DataProtectorSharing SC -kind: pipeline -type: docker -name: sharing-smart-contract update-env - -trigger: - event: - - promote - target: - # configure the staging DataProtectorSharing contract to use the staging environment - - sharing-smart-contract-update-env-staging - # configure the prod DataProtectorSharing contract to use the prod environment - - sharing-smart-contract-update-env-prod - branch: - - main - -steps: - - name: install-deps - image: node:18.19 - pull: always - commands: - - cd packages/sharing-smart-contract - - npm ci - - - name: install-forge - image: node:18.19 - pull: always - commands: - - export XDG_CONFIG_HOME=/drone/src - - curl -L https://foundry.paradigm.xyz | bash - - export PATH="$PATH:/drone/src/.foundry/bin" - - foundryup - - forge install foundry-rs/forge-std --no-git - - - name: smart-contract-staging-update-env - image: node:18.19 - environment: - WALLET_PRIVATE_KEY: - # TODO replace by dataprotector-admin-dev-privatekey - from_secret: deployer-dev-privatekey - ENV: staging - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run update-env -- --network bellecour - depends_on: - - install-forge - - install-deps - when: - target: - - sharing-smart-contract-update-env-staging - - - name: smart-contract-prod-update-env - image: node:18.19 - environment: - WALLET_PRIVATE_KEY: - # TODO replace by dataprotector-admin-prod-privatekey - from_secret: deployer-prod-privatekey - ENV: prod - commands: - - cd packages/sharing-smart-contract - - export PATH="$PATH:/drone/src/.foundry/bin" - - npm run update-env -- --network bellecour - depends_on: - - install-forge - - install-deps - when: - target: - - sharing-smart-contract-update-env-prod - + --- # pipeline to upgrade the DataProtectorSharing SC kind: pipeline diff --git a/packages/smart-contract/.drone.yml b/packages/smart-contract/.drone.yml deleted file mode 100644 index c2895e66e..000000000 --- a/packages/smart-contract/.drone.yml +++ /dev/null @@ -1,47 +0,0 @@ -###################### SMART CONTRACT DRONE CI ###################### -kind: pipeline -type: docker -name: smart-contract-default - -trigger: - event: push - -steps: - - name: install deps - image: node:18.19 - pull: always - commands: - - cd packages/smart-contract - - node -v - - npm -v - - npm ci - - - name: check format - image: node:18.19 - commands: - - cd packages/smart-contract - - npm run check-format - - - name: check lint - image: node:18.19 - commands: - - cd packages/smart-contract - - npm run lint - - - name: compile smart contracts - image: node:18.19 - commands: - - cd packages/smart-contract - - npm run compile - - - name: test smart contracts - image: node:18.19 - commands: - - cd packages/smart-contract - - npm run test - - - name: dry-deployment smart-contract - image: node:18.19 - commands: - - cd packages/smart-contract - - npm run deploy