Skip to content

Commit

Permalink
fix: resolve issue in cicd pipeline (#258)
Browse files Browse the repository at this point in the history
* chore: update deployment

* chore: add cd validation

* chore: update deploy

* chore: update deploy

* chore: update

* chore: update

* chore: update

* chore: update

* chore: restore cache

* Revert "chore: restore cache"

This reverts commit 844fa6c.

* chore: fix typo

* chore: update get-starknet build process
  • Loading branch information
stanleyyconsensys authored Jun 20, 2024
1 parent 6faaf02 commit 35f21e6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 75 deletions.
74 changes: 52 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
type: environment
required: true
jobs:
perpare-deployment:
prepare-deployment:
environment: ${{ inputs.environment }}
permissions:
contents: write
Expand All @@ -28,6 +28,14 @@ jobs:
HASH=$(git rev-parse --short HEAD)
DATE=$(date +%Y%m%d)
ENV=${{ inputs.environment }}
{
echo "AWS_CLOUDFRONT_DISTRIBUTIONS_ID=${{ vars.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}"
echo "AWS_S3_GET_STARKNET_URL=${{ vars.AWS_S3_GET_STARKNET_URL }}"
echo "AWS_S3_URL=${{ vars.AWS_S3_URL }}"
echo "GET_STARKNET_PUBLIC_PATH=${{ vars.GET_STARKNET_PUBLIC_PATH }}"
} >> "$GITHUB_OUTPUT"
if [[ $ENV == "dev" ]]; then
{
echo "VERSION=${BASE}-dev-${HASH}-${DATE}"
Expand All @@ -54,10 +62,14 @@ jobs:
VERSION: ${{ steps.prepare_parameters.outputs.VERSION }}
TAG: ${{ steps.prepare_parameters.outputs.TAG }}
ENV: ${{ steps.prepare_parameters.outputs.ENV }}
AWS_S3_GET_STARKNET_URL: ${{ steps.prepare_parameters.outputs.AWS_S3_GET_STARKNET_URL }}
AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ steps.prepare_parameters.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}
AWS_S3_URL: ${{ steps.prepare_parameters.outputs.AWS_S3_URL }}
GET_STARKNET_PUBLIC_PATH: ${{ steps.prepare_parameters.outputs.GET_STARKNET_PUBLIC_PATH }}

install-build:
needs:
- perpare-deployment
- prepare-deployment
permissions:
contents: write
runs-on: ubuntu-latest
Expand All @@ -75,6 +87,8 @@ jobs:
yarn allow-scripts
- name: Build Snap
run: |
echo "Building Snap with version $VERSION"
npm --prefix ./packages/starknet-snap version --new-version "$VERSION" --no-git-tag-version --allow-same-version
yarn workspace @consensys/starknet-snap build
Expand All @@ -85,27 +99,28 @@ jobs:
echo "Version mismatch"
exit 1
fi
echo "Building UI with version $VERSION"
REACT_APP_SNAP_VERSION="$VERSION" yarn workspace wallet-ui build
echo "Building Get Starknet with GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH"
GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH yarn workspace @consensys/get-starknet build
env:
SNAP_ENV: ${{ needs.perpare-deployment.outputs.ENV }}
VERSION: ${{ needs.perpare-deployment.outputs.VERSION }}
SNAP_ENV: ${{ needs.prepare-deployment.outputs.ENV }}
VERSION: ${{ needs.prepare-deployment.outputs.VERSION }}
VOYAGER_API_KEY: ${{ secrets.VOYAGER_API_KEY }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
- name: Build UI
run: |
REACT_APP_SNAP_VERSION="$VERSION" yarn workspace wallet-ui build
env:
VERSION: ${{ needs.perpare-deployment.outputs.VERSION }}
- name: Build Get Starknet Package
run: GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH yarn workspace @consensys/get-starknet build
env:
GET_STARKNET_PUBLIC_PATH: ${{ vars.GET_STARKNET_PUBLIC_PATH }}
GET_STARKNET_PUBLIC_PATH: ${{ needs.prepare-deployment.outputs.GET_STARKNET_PUBLIC_PATH }}
- name: Cache Build
uses: actions/cache@v3
id: restore-build
with:
path: |
./packages/get-starknet/dist/webpack
./packages/wallet-ui/build
./packages/starknet-snap/package.json
./packages/starknet-snap/dist
./packages/starknet-snap/snap.manifest.json
./node_modules/.yarn-state.yml
Expand All @@ -114,7 +129,7 @@ jobs:
publish-npm-dry-run:
runs-on: ubuntu-latest
needs:
- perpare-deployment
- prepare-deployment
- install-build
steps:
- uses: actions/checkout@v3
Expand All @@ -130,6 +145,9 @@ jobs:
with:
# add /packages/snap/snap.manifest.json to include an updated shasum from build due to version update in auto PR
path: |
./packages/get-starknet/dist/webpack
./packages/wallet-ui/build
./packages/starknet-snap/package.json
./packages/starknet-snap/dist
./packages/starknet-snap/snap.manifest.json
./node_modules/.yarn-state.yml
Expand All @@ -138,13 +156,13 @@ jobs:
run: |
npm pack ./packages/starknet-snap --tag "$TAG" --access public
env:
TAG: ${{ needs.perpare-deployment.outputs.TAG }}
TAG: ${{ needs.prepare-deployment.outputs.TAG }}

publish-npm:
runs-on: ubuntu-latest
needs:
- publish-npm-dry-run
- perpare-deployment
- prepare-deployment
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -159,6 +177,9 @@ jobs:
with:
# add /packages/snap/snap.manifest.json to include an updated shasum from build due to version update in auto PR
path: |
./packages/get-starknet/dist/webpack
./packages/wallet-ui/build
./packages/starknet-snap/package.json
./packages/starknet-snap/dist
./packages/starknet-snap/snap.manifest.json
./node_modules/.yarn-state.yml
Expand All @@ -168,12 +189,12 @@ jobs:
npm publish ./packages/starknet-snap --tag "$TAG" --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG: ${{ needs.perpare-deployment.outputs.TAG }}
TAG: ${{ needs.prepare-deployment.outputs.TAG }}

deploy-wallet-ui:
runs-on: ubuntu-latest
needs:
- perpare-deployment
- prepare-deployment
- publish-npm
steps:
- name: Configure AWS credentials
Expand All @@ -190,20 +211,24 @@ jobs:
id: restore-build
with:
path: |
./packages/get-starknet/dist/webpack
./packages/wallet-ui/build
./packages/starknet-snap/package.json
./packages/starknet-snap/dist
./packages/starknet-snap/snap.manifest.json
./node_modules/.yarn-state.yml
key: ${{ github.sha }}
- name: Deploy to AWS
run: |
echo "Deployed Dapp to : $AWS_S3_URL"
aws s3 sync ./packages/wallet-ui/build "$AWS_S3_URL"
env:
AWS_S3_URL: ${{ vars.AWS_S3_URL }}
AWS_S3_URL: ${{ needs.prepare-deployment.outputs.AWS_S3_URL }}

deploy-get-starknet:
runs-on: ubuntu-latest
needs:
- perpare-deployment
- prepare-deployment
- install-build
steps:
- name: Configure AWS credentials
Expand All @@ -221,20 +246,25 @@ jobs:
with:
path: |
./packages/get-starknet/dist/webpack
./packages/wallet-ui/build
./packages/starknet-snap/package.json
./packages/starknet-snap/dist
./packages/starknet-snap/snap.manifest.json
./node_modules/.yarn-state.yml
key: ${{ github.sha }}
- name: Deploy to AWS
run: |
echo "Deployed get Starknet to : $AWS_S3_GET_STARKNET_URL"
aws s3 sync ./packages/get-starknet/dist/webpack "$AWS_S3_GET_STARKNET_URL"
env:
AWS_S3_GET_STARKNET_URL: ${{ vars.AWS_S3_GET_STARKNET_URL }}
AWS_S3_GET_STARKNET_URL: ${{ needs.prepare-deployment.outputs.AWS_S3_GET_STARKNET_URL }}

invalid-aws-cdn-cache:
runs-on: ubuntu-latest
needs:
- deploy-wallet-ui
- deploy-get-starknet
- prepare-deployment
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -254,4 +284,4 @@ jobs:
echo "Invalidation $INVALIDED_ID completed"
done
env:
AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ vars.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}
AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ needs.prepare-deployment.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}
4 changes: 1 addition & 3 deletions packages/get-starknet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
"url": "https://github.com/ConsenSys/starknet-snap.git"
},
"scripts": {
"start": "webpack-cli serve --config webpack.serve.config.js",
"start": "GET_STARKNET_PUBLIC_PATH=http://localhost:8082/ SNAP_ID=local:http://localhost:8081 yarn build && webpack-cli serve --config webpack.config.local.js",
"clean": "rimraf dist",
"setup": "yarn install --no-immutable",
"build": "webpack --config webpack.config.build.js",
"serve:local": "GET_STARKNET_PUBLIC_PATH=http://localhost:8082/ yarn build && SNAP_ID=local:http://localhost:8081/ webpack-cli serve --config webpack.config.local.js",
"prettier": "prettier --write \"src/**/*.ts\"",
"lint": "eslint 'src/*.{js,ts,tsx}' --max-warnings 0 -f json -o eslint-report.json",
"lint:fix": "eslint '**/*.{js,ts,tsx}' --fix",
Expand Down
5 changes: 5 additions & 0 deletions packages/get-starknet/webpack.config.build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const webpack = require('webpack');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const dotenv = require( "dotenv");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { merge } = require('webpack-merge');
Expand All @@ -16,6 +18,9 @@ module.exports = (env) => merge(common, {
publicPath: process.env.GET_STARKNET_PUBLIC_PATH ?? 'https://snaps.consensys.io/starknet/get-starknet/v1/',
},
plugins: [
new webpack.DefinePlugin({
'process.env.SNAP_ID': JSON.stringify(process.env.SNAP_ID ?? 'npm:@consensys/starknet-snap')
}),
new ModuleFederationPlugin({
name: 'MetaMaskStarknetSnapWallet',
filename: 'remoteEntry.js',
Expand Down
18 changes: 4 additions & 14 deletions packages/get-starknet/webpack.config.local.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const webpack = require('webpack');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { merge } = require('webpack-merge');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const common = require('./webpack.common.js');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
module.exports = merge(common, {

module.exports = {
mode: 'development',
output: {
publicPath: process.env.GET_STARKNET_PUBLIC_PATH ?? 'http://localhost:8082/', // Adjust the development publicPath as needed
Expand All @@ -15,10 +10,5 @@ module.exports = merge(common, {
static: path.join(__dirname, 'dist/webpack'),
compress: true,
port: 8082,
},
plugins: [
new webpack.DefinePlugin({
'process.env.SNAP_ID': JSON.stringify(process.env.SNAP_ID ?? 'http://localhost:8081/')
})
]
});
}
};
36 changes: 0 additions & 36 deletions packages/get-starknet/webpack.serve.config.js

This file was deleted.

0 comments on commit 35f21e6

Please sign in to comment.