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

New workflows #9753

Closed
Closed
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
103 changes: 103 additions & 0 deletions .github/actions/build-and-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

name: Build and Test
description: Install, bootstrap, Build and Test


runs:
using: composite


steps:

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: package-lock.json


- name: Setup Docker
uses: docker/setup-buildx-action@v2

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: |
- "node_modules"
- "packages/account/node_modules"
- "packages/api/node_modules"
- "packages/appstore/node_modules"
- "packages/bot-skeleton/node_modules"
- "packages/bot-web-ui/node_modules"
- "packages/cashier/node_modules"
- "packages/components/node_modules"
- "packages/core/node_modules"
- "packages/hooks/node_modules"
- "packages/cfd/node_modules"
- "packages/indicators/node_modules"
- "packages/p2p/node_modules"
- "packages/reports/node_modules"
- "packages/shared/node_modules"
- "packages/stores/node_modules"
- "packages/trader/node_modules"
- "packages/translations/node_modules"
- "packages/utils/node_modules"
- "packages/analytics/node_modules"

key: node_modules-${{ hashFiles('**/package-lock.json') }}

- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
shell: bash -le {0}

run: |
npm ci
npm run bootstrap

- name: Build
shell: bash -le {0}
run: npm run build:all

- name: "Check TypeScript for @deriv/api"
shell: bash -le {0}
run: npx tsc --project packages/api/tsconfig.json -noEmit

- name: "Check TypeScript for @deriv/hooks"
shell: bash -le {0}
run: npx tsc --project packages/hooks/tsconfig.json -noEmit

- name: "Check TypeScript for @deriv/utils"
shell: bash -le {0}
run: npx tsc --project packages/utils/tsconfig.json -noEmit

- name: "Check TypeScript for @deriv/analytics"
shell: bash -le {0}
run: npx tsc --project packages/analytics/tsconfig.json -noEmit

- name: "Check TypeScript for @deriv/stores"
shell: bash -le {0}
run: npx tsc --project packages/stores/tsconfig.json -noEmit

- name: "Check tests for @deriv/hooks"
shell: bash -le {0}
run: bash ./scripts/check-tests.sh packages/hooks/src

- name: "Check tests for @deriv/utils"
shell: bash -le {0}
run: bash ./scripts/check-tests.sh packages/utils/src

- name: "Check tests for @deriv/analytics"
shell: bash -le {0}
run: bash ./scripts/check-tests.sh packages/analytics/src

- name: "Run tests"
shell: bash -le {0}
run: JEST_MAX_WORKERS=4 npm test


60 changes: 60 additions & 0 deletions .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build and Deploy

on:
push:
branches:
- master

jobs:
build_and_deploy:
# runs-on: [self-hosted] # Specify the label of your self-hosted runner machine

steps:
- name: Build and Test
uses: ./.github/actions/build-and-test

- name: Tag and Version
run: |
echo "${{ github.event_name }}"
if [ "${{ github.event_name }}" == "release" ]; then
echo "::set-output name=version_name::production-${{ github.ref }}"
else
echo "::set-output name=version_name::staging-${{ github.sha }}"
fi

- name: Build and Push image to docker hub
env:
DOCKHUB_ORGANISATION: binary-com # Set your Docker Hub organization
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
TAG=${{ github.event.outputs.version_name }}
docker build -t $DOCKHUB_ORGANISATION/deriv-app:${TAG} -t $DOCKHUB_ORGANISATION/deriv-app:latest-staging -f Dockerfile .
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
docker push $DOCKHUB_ORGANISATION/deriv-app:${TAG}
docker push $DOCKHUB_ORGANISATION/deriv-app:latest-staging

- name: Deploy to k8s cluster
env:
CA_CRT: ${{ secrets.CA_CRT }} # Add your Kubernetes CA_CRT secret here
run: |
TAG=${{ github.event.outputs.version_name }}
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo $CA_CRT | base64 --decode > ca.crt
./release.sh deriv-app ${TAG} "deriv-app-staging" # Adjust parameters as needed

- name: Notify slack
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} # Add your Slack Webhook secret here
run: |
TAG=${{ github.event.outputs.version_name }}
if [ "${{ github.event_name }}" == "release" ]; then
slack/status \
--failure-message "Release failed for app.deriv.com with version *${TAG}*" \
--success-message "Release succeeded for app.deriv.com with version *${TAG}*" \
--webhook "${SLACK_WEBHOOK}"
fi

# Add the steps for publishing to Cloudflare Pages here if needed.

17 changes: 17 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build and Test

on:
pull_request:
branches:
- master

jobs:
build_and_deploy:
# runs-on: [self-hosted] # Specify the label of your self-hosted runner machine
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Build and Test
uses: ./.github/actions/build-and-test
22 changes: 7 additions & 15 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ name: Coveralls

jobs:

build:
name: Reporter
Reporter:
name: Upload Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Bootstrap, Build, and make test-coverage
run: |
npm ci
npm run bootstrap
npm run build:all
JEST_MAX_WORKERS=3 npm run test:jest
- name: Build and Test
uses: ./.github/actions/build-and-test

- name: Coveralls
uses: coverallsapp/github-action@v2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"publish_package": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run publish_package $2 ;}; f",
"serve": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run serve $npm_config_open;}; f",
"start": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run start ;}; f",
"test": "f () { bash ./scripts/circleci-config.test.sh && npm run test:stylelint && npm run test:eslint-all && JEST_MAX_WORKERS=6 npm run test:jest ;}; f",
"test": "f () { bash ./scripts/circleci-config.test.sh && npm run test:stylelint && npm run test:eslint-all && JEST_MAX_WORKERS=${JEST_MAX_WORKERS:-'45%'} npm run test:jest ;}; f",
"test:stylelint": "stylelint \"./packages/*/src/**/*.s(a|c)ss\"",
"test:jest": "jest --all --maxWorkers=${JEST_MAX_WORKERS:-'45%'}",
"test:e2e": "cd end-to-end-test && npx playwright test",
Expand Down
Loading