feat(governance,trading,explorer): pipelines improvements (#3422)
This commit is contained in:
parent
54f2519a62
commit
a9f4604bad
86
.github/workflows/ci-cd-trigger.yml
vendored
86
.github/workflows/ci-cd-trigger.yml
vendored
@ -8,11 +8,49 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
- reopened
|
|
||||||
- synchronize
|
|
||||||
- ready_for_review
|
- ready_for_review
|
||||||
|
- reopened
|
||||||
|
- edited
|
||||||
|
- synchronize
|
||||||
jobs:
|
jobs:
|
||||||
|
node-modules:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
name: 'Cache yarn modules'
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache node modules
|
||||||
|
id: cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
||||||
|
# comment out "resotre-keys" if you need to rebuild yarn from 0
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-cache-node-modules-
|
||||||
|
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
||||||
|
cache: yarn
|
||||||
|
|
||||||
|
- name: yarn install
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
|
run: yarn install --pure-lockfile
|
||||||
|
|
||||||
|
lint-pr-title:
|
||||||
|
needs: node-modules
|
||||||
|
name: Verify PR title
|
||||||
|
uses: ./.github/workflows/lint-pr.yml
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
lint-test-build:
|
lint-test-build:
|
||||||
|
timeout-minutes: 10
|
||||||
|
needs: node-modules
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
name: '(CI) lint + unit test + build'
|
name: '(CI) lint + unit test + build'
|
||||||
steps:
|
steps:
|
||||||
@ -28,8 +66,11 @@ jobs:
|
|||||||
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install root dependencies
|
- name: Cache node modules
|
||||||
run: yarn install --frozen-lockfile
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
||||||
|
|
||||||
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
||||||
uses: nrwl/nx-set-shas@v3
|
uses: nrwl/nx-set-shas@v3
|
||||||
@ -96,6 +137,43 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
projects: ${{ needs.lint-test-build.outputs.projects }}
|
projects: ${{ needs.lint-test-build.outputs.projects }}
|
||||||
|
|
||||||
|
dist-check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: publish-dist
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
name: '(CD) comment preview links'
|
||||||
|
steps:
|
||||||
|
- name: Find Comment
|
||||||
|
uses: peter-evans/find-comment@v2
|
||||||
|
id: fc
|
||||||
|
with:
|
||||||
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
body-includes: Previews
|
||||||
|
|
||||||
|
- name: Inject slug/short variables
|
||||||
|
if: ${{ steps.fc.outputs.comment-id == 0 }}
|
||||||
|
uses: rlespinasse/github-slug-action@v4
|
||||||
|
with:
|
||||||
|
prefix: CI_
|
||||||
|
|
||||||
|
- name: Create comment
|
||||||
|
if: ${{ steps.fc.outputs.comment-id == 0 }}
|
||||||
|
uses: peter-evans/create-or-update-comment@v3
|
||||||
|
with:
|
||||||
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
body: |
|
||||||
|
Previews
|
||||||
|
- explorer https://explorer.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks
|
||||||
|
- trading https://trading.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks
|
||||||
|
- governance https://governance.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks
|
||||||
|
|
||||||
|
cypress-check:
|
||||||
|
name: '(CI) cypress - check'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: cypress
|
||||||
|
steps:
|
||||||
|
- run: echo Done!
|
||||||
|
|
||||||
# Report single result at the end, to avoid mess with required checks in PR
|
# Report single result at the end, to avoid mess with required checks in PR
|
||||||
cypress-result:
|
cypress-result:
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
|
@ -2,15 +2,11 @@
|
|||||||
name: Verify PR title
|
name: Verify PR title
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- ready_for_review
|
|
||||||
- reopened
|
|
||||||
- edited
|
|
||||||
- synchronize
|
|
||||||
jobs:
|
jobs:
|
||||||
lint_pr:
|
lint_pr:
|
||||||
|
timeout-minutes: 10
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -23,8 +19,11 @@ jobs:
|
|||||||
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install root dependencies
|
- name: Cache node modules
|
||||||
run: yarn install --frozen-lockfile
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
||||||
|
|
||||||
- name: Check PR title
|
- name: Check PR title
|
||||||
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --config ./commitlint.config-ci.js
|
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --config ./commitlint.config-ci.js
|
65
.github/workflows/publish-dist.yml
vendored
65
.github/workflows/publish-dist.yml
vendored
@ -15,6 +15,7 @@ jobs:
|
|||||||
app: ${{ fromJSON(inputs.projects) }}
|
app: ${{ fromJSON(inputs.projects) }}
|
||||||
name: ${{ matrix.app }}
|
name: ${{ matrix.app }}
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -36,48 +37,91 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
||||||
|
cache: yarn
|
||||||
|
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
||||||
|
|
||||||
# https://docs.github.com/en/actions/learn-github-actions/contexts
|
# https://docs.github.com/en/actions/learn-github-actions/contexts
|
||||||
- name: Define variables
|
- name: Define variables
|
||||||
id: tags
|
|
||||||
run: |
|
run: |
|
||||||
|
envName=''
|
||||||
|
dockerfile="dist.Dockerfile"
|
||||||
if [[ "${{ github.event_name }}" = "push" ]]; then
|
if [[ "${{ github.event_name }}" = "push" ]]; then
|
||||||
domain="vega.rocks"
|
domain="vega.rocks"
|
||||||
if [[ "${{ github.ref }}" =~ .*release/.* ]]; then
|
if [[ "${{ github.ref }}" =~ .*release/.* ]]; then
|
||||||
envName="$(echo ${{ github.ref }} | rev | cut -d '/' -f 1 | rev)"
|
envName="$(echo ${{ github.ref }} | rev | cut -d '/' -f 1 | rev)"
|
||||||
if [[ "${{ github.ref }}" =~ .*mainnet.* ]]; then
|
if [[ "${{ github.ref }}" =~ .*mainnet.* ]]; then
|
||||||
domain="vega.community"
|
domain="vega.community"
|
||||||
|
if [[ "${{ matrix.app }}" = "trading" ]]; then
|
||||||
|
dockerfile="ipfs.Dockerfile"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ "${{ github.ref }}" =~ .*develop$ ]]; then
|
elif [[ "${{ github.ref }}" =~ .*develop$ ]]; then
|
||||||
envName="stagnet3"
|
envName="stagnet3"
|
||||||
fi
|
fi
|
||||||
bucketName="${{ matrix.app }}.${envName}.${domain}"
|
bucketName="${{ matrix.app }}.${envName}.${domain}"
|
||||||
echo ::set-output name=bucketName::${bucketName}
|
echo BUCKET_NAME=${bucketName} >> $GITHUB_ENV
|
||||||
echo ::set-output name=envName::${envName}
|
|
||||||
fi
|
fi
|
||||||
nodeVersion=$(cat .nvmrc | head -n 1)
|
nodeVersion=$(cat .nvmrc | head -n 1)
|
||||||
echo ::set-output name=nodeVersion::${nodeVersion}
|
echo ENV_NAME=${envName} >> $GITHUB_ENV
|
||||||
|
echo NODE_VERSION=${nodeVersion} >> $GITHUB_ENV
|
||||||
|
echo DOCKERFILE=docker/${dockerfile} >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build local dist
|
||||||
|
if: ${{ env.DOCKERFILE != 'docker/ipfs.Dockerfile' }}
|
||||||
|
run: |
|
||||||
|
flags=""
|
||||||
|
if [[ ! -z "${{ env.ENV_NAME }}" ]]; then
|
||||||
|
if [[ "${{ env.ENV_NAME }}" != "ops-vega" ]]; then
|
||||||
|
flags="--env=${{ env.ENV_NAME }}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ matrix.app }}" = "trading" ]; then
|
||||||
|
yarn nx export trading $flags || (yarn install && yarn nx export trading $flags)
|
||||||
|
DIST_LOCATION=dist/apps/trading/exported
|
||||||
|
else
|
||||||
|
yarn nx build ${{ matrix.app }} $flags || (yarn install && yarn nx build ${{ matrix.app }} $flags)
|
||||||
|
DIST_LOCATION=dist/apps/${{ matrix.app }}
|
||||||
|
fi
|
||||||
|
mv $DIST_LOCATION dist-result
|
||||||
|
tree dist-result
|
||||||
|
|
||||||
- name: Build and export to local Docker
|
- name: Build and export to local Docker
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
|
context: .
|
||||||
|
file: ${{ env.DOCKERFILE }}
|
||||||
load: true
|
load: true
|
||||||
build-args: |
|
build-args: |
|
||||||
APP=${{ matrix.app }}
|
APP=${{ matrix.app }}
|
||||||
NODE_VERSION=${{ steps.tags.outputs.nodeVersion }}
|
NODE_VERSION=${{ env.NODE_VERSION }}
|
||||||
ENV_NAME=${{ steps.tags.outputs.envName || '' }}
|
ENV_NAME=${{ env.ENV_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local
|
ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local
|
||||||
|
|
||||||
- name: Sanity check docker image
|
- name: Sanity check docker image
|
||||||
run: |
|
run: |
|
||||||
echo "Check ipfs-hash"
|
echo "Check ipfs-hash"
|
||||||
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local cat ipfs-hash
|
if [[ "${{ env.DOCKERFILE }}" = "docker/ipfs.Dockerfile" ]]; then
|
||||||
|
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local cat /ipfs-hash
|
||||||
|
fi
|
||||||
|
|
||||||
echo "List html directory"
|
echo "List html directory"
|
||||||
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local sh -c 'apk add --update tree; tree .'
|
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local sh -c 'apk add --update tree; tree .'
|
||||||
|
|
||||||
- name: Copy dist to local filesystem
|
- name: Copy dist to local filesystem
|
||||||
|
if: ${{ env.DOCKERFILE != 'docker/ipfs.Dockerfile' }}
|
||||||
run: |
|
run: |
|
||||||
docker create --name=dist ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local
|
docker create --name=dist ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local
|
||||||
docker cp dist:/usr/share/nginx/html dist
|
docker cp dist:/usr/share/nginx/html dist
|
||||||
@ -89,10 +133,13 @@ jobs:
|
|||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
with:
|
with:
|
||||||
|
context: .
|
||||||
|
file: ${{ env.DOCKERFILE }}
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
build-args: |
|
||||||
APP=${{ matrix.app }}
|
APP=${{ matrix.app }}
|
||||||
NODE_VERSION=${{ steps.tags.outputs.nodeVersion }}
|
NODE_VERSION=${{ env.NODE_VERSION }}
|
||||||
|
ENV_NAME=${{ env.ENV_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:${{ github.event.pull_request.head.sha || github.sha }}
|
ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
|
||||||
@ -107,7 +154,7 @@ jobs:
|
|||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
AWS_REGION: 'eu-west-1'
|
AWS_REGION: 'eu-west-1'
|
||||||
SOURCE_DIR: 'dist/${{ matrix.app }}'
|
SOURCE_DIR: 'dist'
|
||||||
|
|
||||||
- name: Add preview label
|
- name: Add preview label
|
||||||
uses: actions-ecosystem/action-add-labels@v1
|
uses: actions-ecosystem/action-add-labels@v1
|
||||||
|
6
docker/dist.Dockerfile
Normal file
6
docker/dist.Dockerfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM --platform=amd64 nginx:1.23-alpine@sha256:6318314189b40e73145a48060bff4783a116c34cc7241532d0d94198fb2c9629
|
||||||
|
EXPOSE 80
|
||||||
|
WORKDIR /usr/share/nginx/html
|
||||||
|
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
|
COPY ./dist-result/ /usr/share/nginx/html/
|
@ -13,7 +13,7 @@ RUN apk add --update --no-cache \
|
|||||||
COPY . ./
|
COPY . ./
|
||||||
RUN yarn --network-timeout 100000 --pure-lockfile
|
RUN yarn --network-timeout 100000 --pure-lockfile
|
||||||
# work around for different build process in trading
|
# work around for different build process in trading
|
||||||
RUN sh ./docker-build.sh
|
RUN sh docker/docker-build.sh
|
||||||
|
|
||||||
# Server environment
|
# Server environment
|
||||||
# if this fails you need to docker pull nginx:1.23-alpine and pin new SHA
|
# if this fails you need to docker pull nginx:1.23-alpine and pin new SHA
|
||||||
@ -23,7 +23,7 @@ FROM --platform=amd64 nginx:1.23-alpine@sha256:6318314189b40e73145a48060bff4783a
|
|||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
# Copy dist
|
# Copy dist
|
||||||
WORKDIR /usr/share/nginx/html
|
WORKDIR /usr/share/nginx/html
|
||||||
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
RUN rm -rf /usr/share/nginx/html/*
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
COPY --from=build /app/dist/apps/${APP} /usr/share/nginx/html
|
COPY --from=build /app/dist/apps/${APP}/* /usr/share/nginx/html
|
||||||
RUN apk add --no-cache go-ipfs; ipfs init && echo "$(ipfs add -rQ .)" > ipfs-hash; apk del go-ipfs
|
RUN apk add --no-cache go-ipfs; ipfs init && echo "$(ipfs add -rQ .)" > /ipfs-hash; apk del go-ipfs
|
Loading…
Reference in New Issue
Block a user