Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Upgrade to TS #7

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
281 changes: 281 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
name: CI/CD Workflow

on:
workflow_dispatch:
push:
branches:
- '**'
# pull_request:
# types:
# - closed

jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: ponicode/azure-devops-npm-action@master
with:
organisation: precise-finance
project: precise-finance
registry: precise-npm
user: danshapir
password: ${{ secrets.AZURE_PAT }}
email: [email protected]
# scope: ponicode
- run: cp `pwd`/.npmrc ~ # We need the .npmrc file in the $HOME directory
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '18' # Adjust as necessary

- name: Cache node_modules
id: cache-node-modules # Added an ID for this step
uses: actions/cache@v3
with:
path: node_modules # caching node_modules directly
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-

- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true' # Only run if cache was a miss
run: npm ci

- name: Run tests
run: |
npx prisma generate
npm run test:ci

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: JEST Tests # Name of the check run which will be created
path: reports/jest-*.xml # Path to test results
reporter: jest-junit # Format of test results

build_image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout Helm repo
uses: actions/checkout@v4
with:
repository: Precise-Finance/charts
path: helm-repo
ref: main
token: ${{ secrets.GH_SECRET }}

- name: Install yq
run: |
sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.12.2/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq

- name: Get current image tag
id: get_current_tag
run: |
CURRENT_TAG=$(yq eval ".image.tag" helm-repo/${{ github.event.repository.name }}/values.yaml)
echo "current_tag=$CURRENT_TAG" >> $GITHUB_OUTPUT

- name: Check if tag needs update
id: check_tag
run: |
if [[ "${{ steps.get_current_tag.outputs.current_tag }}" == "$GITHUB_SHA" ]]; then
echo "Image tag is already up-to-date. Skipping."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi

- name: Azure npm auth
if: steps.check_tag.outputs.skip == 'false'
uses: ponicode/azure-devops-npm-action@master
with:
organisation: precise-finance
project: precise-finance
registry: precise-npm
user: danshapir
password: ${{ secrets.AZURE_PAT }}
email: [email protected]
# scope: ponicode
- run: cp `pwd`/.npmrc ~ # We need the .npmrc file in the $HOME directory
- name: Setup Node.js
if: steps.check_tag.outputs.skip == 'false'
uses: actions/[email protected]
with:
node-version: '18' # Adjust as necessary

- name: Configure AWS credentials
if: steps.check_tag.outputs.skip == 'false'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1

- name: Login to Amazon ECR Private
if: steps.check_tag.outputs.skip == 'false'
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Set up Docker Buildx
if: steps.check_tag.outputs.skip == 'false'
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
if: steps.check_tag.outputs.skip == 'false'
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-buildx-


- name: Build, tag, and push docker image to Amazon ECR using Buildx
if: steps.check_tag.outputs.skip == 'false'
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: precise/${{ github.event.repository.name }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker buildx create --use
docker buildx build --push \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \
--build-arg BUILDKIT_INLINE_CACHE=1 \
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG .




- name: Update values.yaml
if: steps.check_tag.outputs.skip == 'false'
run: |
yq eval ".image.tag = \"$(echo $GITHUB_SHA )\"" -i helm-repo/${{ github.event.repository.name }}/values.yaml
cat helm-repo/${{ github.event.repository.name }}/values.yaml


- name: Set up Git
if: steps.check_tag.outputs.skip == 'false'
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"

- name: Commit and Push Changes
if: steps.check_tag.outputs.skip == 'false'
run: |
cd helm-repo
git add .
git commit -m "Update image tag after commit"
git push

- name: Generate File
run: |
cd helm-repo
echo $(git rev-parse HEAD) > ../helm_commit.txt

- name: Upload artifact
uses: actions/[email protected]
with:
name: helm-commit
path: helm_commit.txt


approval_and_tag_dev:
needs: [run_tests, build_image] # Change the dependency to the newly separated jobs
if: contains(github.ref, 'refs/pull/') || startsWith(github.ref, 'refs/heads/feature/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifact
uses: actions/[email protected]
with:
name: helm-commit
path: helm-commit
- name: Set output
id: get_commit_id
run: |
echo $(cat helm-commit/helm_commit.txt)
echo "commit_id=$(cat helm-commit/helm_commit.txt)" >> $GITHUB_OUTPUT

- name: Get Commit Details
id: get_commit_details
run: |
echo $(git log -1 --pretty=format:'%s')
echo "commit_message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_OUTPUT

- name: Get PR Details
id: get_pr_details
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "pr_link=${{ github.event.pull_request.html_url }}" >> $GITHUB_OUTPUT
else
echo "Not a PR event, skipping PR details extraction."
fi

- name: send approval
uses: Precise-Finance/[email protected]
env:
SLACK_APP_TOKEN: ${{ secrets.SLACK_APP_TOKEN }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
SLACK_CHANNEL_ID: deployment-approvals-dev #${{ secrets.SLACK_CHANNEL_ID }}
DEPLOYMENT_ENV: DEV
COMMIT_SHA: ${{ steps.get_commit_id.outputs.commit_id }}
GH_SECRET: ${{ secrets.GH_SECRET }}
PR_LINK: ${{ steps.get_pr_details.outputs.pr_link }}
COMMIT_MESSAGE: ${{ steps.get_commit_details.outputs.commit_message }}
timeout-minutes: 10

approval_and_tag_prod:
needs: [run_tests, build_image] # Change the dependency to the newly separated jobs
if: (github.ref == 'refs/heads/main') || (github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifact
uses: actions/[email protected]
with:
name: helm-commit
path: helm-commit
- name: Set output
id: get_commit_id
run: |
echo $(cat helm-commit/helm_commit.txt)
echo "commit_id=$(cat helm-commit/helm_commit.txt)" >> $GITHUB_OUTPUT

- name: Get Commit Details
id: get_commit_details
run: |
echo $(git log -1 --pretty=format:'%s')
echo "commit_message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_OUTPUT

- name: Get PR Details
id: get_pr_details
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "pr_link=${{ github.event.pull_request.html_url }}" >> $GITHUB_OUTPUT
else
echo "Not a PR event, skipping PR details extraction."
fi

- name: send approval
uses: Precise-Finance/[email protected]
env:
SLACK_APP_TOKEN: ${{ secrets.SLACK_APP_TOKEN }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
SLACK_CHANNEL_ID: deployment-approvals #${{ secrets.SLACK_CHANNEL_ID }}
DEPLOYMENT_ENV: Production
COMMIT_SHA: ${{ steps.get_commit_id.outputs.commit_id }}
GH_SECRET: ${{ secrets.GH_SECRET }}
PR_LINK: ${{ steps.get_pr_details.outputs.pr_link }}
COMMIT_MESSAGE: ${{ steps.get_commit_details.outputs.commit_message }}
timeout-minutes: 10
32 changes: 32 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Continue Deployment after Approval

on:
repository_dispatch:
types: [deployment-approved]

jobs:
post_approval_prod:
runs-on: ubuntu-latest
steps:
- name: Deploy to environment
run: |
echo "Deploying to ${{ github.event.client_payload.env }}"

- name: Deploy commit
run: |
echo "Deploying commit ${{ github.event.client_payload.sha }}"
- name: Checkout Helm repo at specific SHA
uses: actions/checkout@v4
with:
repository: Precise-Finance/charts
path: helm-repo
ref: ${{ github.event.client_payload.sha }}
token: ${{ secrets.GH_SECRET }}


- name: Tag with SHA and ENV
run: |
cd helm-repo
git tag ${{ github.event.client_payload.env }}-${{ github.event.repository.name }}
git push origin refs/tags/${{ github.event.client_payload.env }}-${{ github.event.repository.name }} -f --tags

38 changes: 38 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Code Review

permissions:
contents: read
pull-requests: write

on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled]

jobs:
chatgpt_review:
if: ${{ !contains(github.event.*.labels.*.name, 'no gpt review') }} # Optional; to run only when a label is attached
runs-on: ubuntu-latest
steps:
- uses: anc95/ChatGPT-CodeReview@main
env:
GITHUB_TOKEN: ${{ secrets.GH_SECRET }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# Optional
LANGUAGE: English
MODEL: gpt-3.5-turbo # https://platform.openai.com/docs/models
# OPENAI_API_ENDPOINT: https://api.openai.com/v1
# PROMPT: Please check if there are any confusions, irregularities, security issues or performance issues in the following code diff:
# top_p: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p
# temperature: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature
# max_tokens: 10000
# MAX_PATCH_LENGTH: 10000 # if the patch/diff length is large than MAX_PATCH_LENGTH, will be ignored and won't review. By default, with no MAX_PATCH_LENGTH set, there is also no limit for the patch/diff length.
gpt_review_node:
if: ${{ contains(github.event.*.labels.*.name, 'gpt summary') }} # Optional; to run only when a label is attached
runs-on: ubuntu-latest
steps:
- name: gpt-review-node
uses: Precise-Finance/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GH_SECRET }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_ORG_KEY: ${{ secrets.OPENAI_ORG_KEY }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ typings/

# IDE
.idea


.history
.DS_Store
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ You can click on the :book: icon to access the detailed API reference for each m
* ```delete(bank_id, callback)``` [:book:](https://docs.checkbook.io/reference#delete-bank)
* ```instantAccountVerification(params, callback[, idempotencyKey])``` [:book:](https://docs.checkbook.io/reference#post-bank-iav)
* ```addBankAccount(params, callback[, idempotencyKey])``` [:book:](https://docs.checkbook.io/reference#post-bank)
* ```verifyMicrodesposits(params, callback)``` [:book:](https://docs.checkbook.io/reference#post-bank-verify)
* ```releaseMicrodeposits(params, callback)``` [:book:](https://docs.checkbook.io/reference#post-bank-release)
* ```verifyMicrodeposits(params, callback)``` [:book:](https://docs.checkbook.io/reference#post-bank-verify)

* __Checkbook.users__
* ```create(params, callback[, idempotencyKey])``` [:book:](https://docs.checkbook.io/reference#post-user)
Expand Down
2 changes: 2 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import CheckbookAPI from "./ts/checkbook";
export default CheckbookAPI;
5 changes: 5 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading