Skip to content

Commit

Permalink
feat!: update app for typeorm (#51)
Browse files Browse the repository at this point in the history
* refactor: update app for typeorm

* refactor: add renovate config

* refactor: handle public scenario
  • Loading branch information
pyphilia authored Jun 13, 2023
1 parent a476be2 commit ddd7097
Show file tree
Hide file tree
Showing 89 changed files with 6,239 additions and 4,781 deletions.
16 changes: 8 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ module.exports = {
'eslint:recommended',
'plugin:cypress/recommended',
'react-app',
'plugin:@typescript-eslint/recommended',
],
parser: '@babel/eslint-parser', // Uses babel-eslint transforms.
globals: {
cy: true,
Cypress: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-react'],
},
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['import'],
root: true, // For configuration cascading.
rules: {},
settings: {
Expand Down
54 changes: 34 additions & 20 deletions .github/workflows/cdelivery-s3-apps-caller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,37 @@ on:

# This workflow is made up of one job that calls the reusable workflow in graasp-deploy
jobs:
graasp-deploy-s3-apps-workflow:
name: Quiz app
# Replace 'main' with the hash of a commit, so it points to an specific version of the reusable workflow that is used
# Reference reusable workflow file. Using the commit SHA is the safest for stability and security
uses: graasp/graasp-deploy/.github/workflows/cdelivery-s3-apps.yml@v1
# Replace input build-folder or version if needed
with:
build-folder: 'build'
version: 'latest'
tag: ${{ github.event.client_payload.tag }}
# Insert required secrets based on repository with the following format: ${{ secrets.SECRET_NAME }}
secrets:
app-id: ${{ secrets.APP_ID }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_STAGE }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGE }}
aws-region: ${{ secrets.APPS_AWS_REGION }}
aws-s3-bucket-name: ${{ secrets.AWS_S3_BUCKET_NAME_APPS_STAGE }}
graasp-domain: ${{ secrets.STAGE_GRAASP_DOMAIN }}
cloudfront-distribution-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_APPS_STAGE }}
sentry-dsn: ${{ secrets.SENTRY_DSN }}
deploy-app-to-staging:
name: Deploy to staging
runs-on: ubuntu-latest
environment: staging
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.client_payload.tag }}

- name: Yarn install and Cache dependencies
uses: graasp/graasp-deploy/.github/actions/yarn-install-and-cache@v1

- name: Yarn build
# Set environment variables required to perform the build. These are only available to this step
env:
REACT_APP_API_HOST: ${{ secrets.REACT_APP_API_HOST_STAGE }}
REACT_APP_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: yarn build
shell: bash

- name: Deploy
uses: graasp/graasp-deploy/.github/actions/deploy-s3-app@v1
# Replace input build-folder or version if needed
with:
build-folder: 'build'
graasp-app-id: ${{ secrets.APP_ID }}
version: 'latest'
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_STAGE }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGE }}
aws-region: ${{ secrets.APPS_AWS_REGION }}
aws-s3-bucket-name: ${{ secrets.AWS_S3_BUCKET_NAME_APPS_STAGE }}
cloudfront-distribution-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_APPS_STAGE }}
54 changes: 34 additions & 20 deletions .github/workflows/cdeployment-s3-apps-caller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,37 @@ on:

# This workflow is made up of one job that calls the reusable workflow in graasp-deploy
jobs:
graasp-deploy-s3-apps-workflow:
name: Quiz app
# Replace 'main' with the hash of a commit, so it points to an specific version of the reusable workflow that is used
# Reference reusable workflow file. Using the commit SHA is the safest for stability and security
uses: graasp/graasp-deploy/.github/workflows/cdeployment-s3-apps.yml@v1
# Replace input build-folder or version if needed.
with:
build-folder: 'build'
version: 'latest'
tag: ${{ github.event.client_payload.tag }}
# Insert required secrets based on repository with the following format: ${{ secrets.SECRET_NAME }}
secrets:
app-id: ${{ secrets.APP_ID }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}
aws-region: ${{ secrets.APPS_AWS_REGION }}
aws-s3-bucket-name: ${{ secrets.AWS_S3_BUCKET_NAME_APPS_PROD }}
graasp-domain: ${{ secrets.PROD_GRAASP_DOMAIN }}
cloudfront-distribution-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_APPS_PROD }}
sentry-dsn: ${{ secrets.SENTRY_DSN }}
deploy-app-to-prod:
name: Deploy to production
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.client_payload.tag }}

- name: Yarn install and Cache dependencies
uses: graasp/graasp-deploy/.github/actions/yarn-install-and-cache@v1

- name: Yarn build
# Set environment variables required to perform the build. These are only available to this step
env:
REACT_APP_API_HOST: ${{ secrets.REACT_APP_API_HOST_PROD }}
REACT_APP_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: yarn build
shell: bash

- name: Deploy
uses: graasp/graasp-deploy/.github/actions/deploy-s3-app@v1
# Replace input build-folder or version if needed
with:
build-folder: 'build'
graasp-app-id: ${{ secrets.APP_ID }}
version: 'latest'
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}
aws-region: ${{ secrets.APPS_AWS_REGION }}
aws-s3-bucket-name: ${{ secrets.AWS_S3_BUCKET_NAME_APPS_PROD }}
cloudfront-distribution-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_APPS_PROD }}
52 changes: 32 additions & 20 deletions .github/workflows/cintegration-s3-apps-caller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,36 @@ on:
# Allows to run the workflow manually from the Actions tab
workflow_dispatch:

# This workflow is made up of one job that calls the reusable workflow in graasp-deploy
jobs:
graasp-deploy-s3-apps-workflow:
name: Quiz app
# Replace 'main' with the hash of a commit, so it points to an specific version of the reusable workflow that is used
# Reference reusable workflow file. Using the commit SHA is the safest for stability and security
uses: graasp/graasp-deploy/.github/workflows/cintegration-s3-apps.yml@v1
# Replace input build-folder or version if needed
with:
build-folder: 'build'
version: 'latest'
# Insert required secrets based on repository with the following format: ${{ secrets.SECRET_NAME }}
secrets:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
aws-region: ${{ secrets.APPS_AWS_REGION }}
aws-s3-bucket-name: ${{ secrets.AWS_S3_BUCKET_NAME_APPS_DEV }}
app-id: ${{ secrets.APP_ID }}
graasp-domain: ${{ secrets.DEV_GRAASP_DOMAIN }}
cloudfront-distribution-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_APPS_DEV }}
sentry-dsn: ${{ secrets.SENTRY_DSN }}
deploy-app:
name: Deploy to dev
runs-on: ubuntu-latest
environment: development
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Yarn install and Cache dependencies
uses: graasp/graasp-deploy/.github/actions/yarn-install-and-cache@v1

- name: Yarn build
# Set environment variables required to perform the build. These are only available to this step
env:
REACT_APP_API_HOST: ${{ secrets.REACT_APP_API_HOST_DEV }}
REACT_APP_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: yarn build
shell: bash

- name: Deploy
uses: graasp/graasp-deploy/.github/actions/deploy-s3-app@v1
# Replace input build-folder or version if needed
with:
build-folder: 'build'
graasp-app-id: ${{ secrets.APP_ID }}
version: 'latest'
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
aws-region: ${{ secrets.APPS_AWS_REGION }}
aws-s3-bucket-name: ${{ secrets.AWS_S3_BUCKET_NAME_APPS_DEV }}
cloudfront-distribution-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_APPS_DEV }}
104 changes: 84 additions & 20 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,89 @@
name: Cypress
name: cypress tests

# Control when the action will run
on:
# Triggers the workflow on push events except for the main branch
push:
branches-ignore:
- 'release-please-**'

# This workflow is made up of one job that calls the reusable workflow in graasp-deploy
jobs:
graasp-deploy-cypress-workflow:
# Replace with repository name
name: Graasp app quiz
# Replace 'main' with the hash of a commit, so it points to an specific version of the reusable workflow that is used
# Reference reusable workflow file. Using the commit SHA is the safest for stability and security
uses: graasp/graasp-deploy/.github/workflows/cypress.yml@v1
# Insert required inputs based on repository
with:
# Test values
node-env-test: test
graasp-domain-test: localhost
graasp-app-id-test: id-1234567890
enable-mock-api-test: true
# Insert required secrets based on repository with the following format: ${{ secrets.SECRET_NAME }}
secrets:
api-host-test: ${{ secrets.REACT_APP_API_HOST_TEST }}
cypress-run:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: set up node
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Yarn Install and Cache
uses: graasp/graasp-deploy/.github/actions/yarn-install-and-cache@v1
with:
cypress: true

- name: cypress run
uses: cypress-io/github-action@v5
env:
REACT_APP_API_HOST: http://localhost:3636
REACT_APP_GRAASP_DOMAIN: localhost
REACT_APP_GRAASP_APP_KEY: id-1234567890
REACT_APP_ENABLE_MOCK_API: true
NODE_ENV: test
with:
install: false
build: yarn build
config: baseUrl=http://localhost:3000
start: yarn start:ci
wait-on: 'http://localhost:3000'
wait-on-timeout: 180
browser: chrome
quiet: true
# point to new cypress@10 config file
config-file: cypress.config.ts

# component tests are not running ok in the CI
# - name: Run Component tests 🧪
# uses: cypress-io/github-action@v4
# with:
# # we have already installed everything
# install: false
# # to run component tests we need to use "component: true"
# component: true

# after the test run completes
# store videos and any screenshots
# NOTE: screenshots will be generated only if E2E test failed
# thus we store screenshots only on failures
# Alternative: create and commit an empty cypress/screenshots folder
# to always have something to upload
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots

- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-videos
path: cypress/videos

- name: coverage report
run: npx nyc report --reporter=text-summary

- name: coverage commit status
run: |
total=$(cat coverage/coverage-summary.json | jq .total.lines.pct)
echo Total coverage ${total}
curl -S -s \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
https://api.github.com/repos/${REPO_PATH}/statuses/${COMMIT_SHA} \
-d "{\"state\":\"success\",\"target_url\":\"https://github.com/${REPO_PATH}/actions/runs/${RUN_ID}\",\"description\":\"${total}%\",\"context\":\"code-coverage\"}"
env:
GITHUB_TOKEN: ${{ github.token }}
REPO_PATH: ${{ github.repository }}
COMMIT_SHA: ${{ github.sha }}
RUN_ID: ${{ github.run_id }}
74 changes: 74 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Automate releases of new app versions
name: Release new app version

on:
push:
branches:
- 'main'

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
# TODO: replace this with your app name
package-name: graasp-app-quiz
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"docs","section":"Documentation","hidden":false},{"type":"test","section":"Tests","hidden":false}]'

- uses: actions/checkout@v3

# creates minor and major tags that follow the latest release
- name: Tag major and minor versions
uses: jacobsvante/[email protected]
if: ${{ steps.release.outputs.release_created }}
with:
major: ${{ steps.release.outputs.major }}
minor: ${{ steps.release.outputs.minor }}

# put created tag in an env variable to be sent to the dispatch
- name: Set tag
if: ${{ steps.release.outputs.release_created }}
id: set-tag
run: |
REPOSITORY=$(echo '${{ github.repository }}')
TAG=$(echo '${{ steps.release.outputs.tag_name }}')
JSON=$(jq -c --null-input --arg repository "$REPOSITORY" --arg tag "$TAG" '{"repository": $repository, "tag": $tag}')
echo "json=$JSON" >> $GITHUB_OUTPUT
# Trigger an 'on: repository_dispatch' workflow to run in graasp-deploy repository
- name: Push tag to Graasp Deploy (Staging)
if: ${{ steps.release.outputs.release_created }}
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: graasp/graasp-deploy
event-type: update-staging-version
client-payload: ${{ steps.set-tag.outputs.json }}

- name: Auto Tag
id: auto-tag
if: ${{ steps.release.outputs.releases_created }}
run: |
gh label create ${{ env.TAG_NAME }} -f --color 0E8A16 --repo ${{ env.REPO }};
echo '### `${{ env.TAG_NAME }}` :rocket:' >> $GITHUB_STEP_SUMMARY;
echo 'Tag all ${{ env.PRE_LABEL_NAME }} issues and prs as ${{ env.TAG_NAME }}';
for cmd in issue pr;
do
for nbr in $(gh $cmd list -l ${{ env.PRE_LABEL_NAME }} -s all --json number --jq '.[].number' --repo ${{ env.REPO }} );
do
URL=$(gh $cmd edit $nbr --add-label ${{ env.TAG_NAME }} --remove-label ${{ env.PRE_LABEL_NAME }} --repo ${{ env.REPO }} );
echo "- $cmd #$nbr $URL" >> $GITHUB_STEP_SUMMARY;
done
done
echo '' >> $GITHUB_STEP_SUMMARY;
echo ':rocket: All related issues and prs tagged !' >> $GITHUB_STEP_SUMMARY;
echo ':scroll: Check out [the created release](${{ env.RELEASE_URL }}) !' >> $GITHUB_STEP_SUMMARY;
env:
GITHUB_TOKEN: ${{ github.token }}
TAG_NAME: ${{ steps.release.outputs.tag_name }}
PRE_LABEL_NAME: un-released
REPO: ${{ github.event.repository.full_name }}
RELEASE_URL: ${{ github.event.repository.html_url }}/releases/tag/${{ steps.release.outputs.tag_name }}
Loading

0 comments on commit ddd7097

Please sign in to comment.