From fa1beb5c651a90ea09d4fb7e32efcca1283b7cff Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Wed, 22 Jun 2022 14:39:33 +0300 Subject: [PATCH 1/8] APP-23838: Integration tests using real db --- .github/workflows/node-testing-workflow.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/node-testing-workflow.yaml b/.github/workflows/node-testing-workflow.yaml index 3d2ca4f..5f1b358 100644 --- a/.github/workflows/node-testing-workflow.yaml +++ b/.github/workflows/node-testing-workflow.yaml @@ -34,6 +34,10 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: '1234' # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it From 94f91f86d80484ed91200fee27241f3c6471b038 Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Thu, 23 Jun 2022 12:44:38 +0300 Subject: [PATCH 2/8] Integration tests using real db --- .github/actions/testing/action.yml | 39 +++++++++++++++ .../node-testing-with-dbs-workflow.yaml | 49 +++++++++++++++++++ .github/workflows/node-testing-workflow.yaml | 26 ++-------- 3 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 .github/actions/testing/action.yml create mode 100644 .github/workflows/node-testing-with-dbs-workflow.yaml diff --git a/.github/actions/testing/action.yml b/.github/actions/testing/action.yml new file mode 100644 index 0000000..06e9473 --- /dev/null +++ b/.github/actions/testing/action.yml @@ -0,0 +1,39 @@ +name: 'Testing' + +inputs: + npm_token: + description: 'npm_token' + required: true + node_v: + type: string + required: false + default: "12.14.1" + redis_url: + type: string + required: false + db_url: + type: string + required: false + +runs: + using: "composite" + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + with: + persist-credentials: false + - name: setup node + uses: actions/setup-node@master + with: + node-version: ${{ inputs.node_v }} + + # install application dependencies + - uses: c-hive/gha-npm-cache@v1 + - name: Install Dependencies + run: npm install + - name: Run tests + env: + REDIS_URL: ${{ inputs.redis_url }} + DB_URL: ${{ inputs.db_url }} + run: | + env IS_LOCAL_LOG=true npm run test \ No newline at end of file diff --git a/.github/workflows/node-testing-with-dbs-workflow.yaml b/.github/workflows/node-testing-with-dbs-workflow.yaml new file mode 100644 index 0000000..90a96e7 --- /dev/null +++ b/.github/workflows/node-testing-with-dbs-workflow.yaml @@ -0,0 +1,49 @@ +name: Node testing workflow + +on: + workflow_call: + secrets: + NPM_TOKEN: + required: true + inputs: + node_v: + type: string + required: false + default: "12.14.1" +env: + ## Sets environment variable + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_OPTIONS: "--max-old-space-size=4096" +jobs: + testing: + # The type of runner that the job will run on + # Containers must run in Linux based operating systems + runs-on: app_backend + + container: node:${{ inputs.node_v }} + + # Service containers to add` + services: + # Label used to access the service container + redis: + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + mysql: + image: mysql:5.7 + ports: + - 3306:3306 + env: + MYSQL_ROOT_PASSWORD: '1234' + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Build and push image + uses: totango/shared-github-actions/.github/actions/testing@add-testing-workflow-mysql + id: image + with: + node_v: ${{ inputs.node_v }} + npm_token: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/node-testing-workflow.yaml b/.github/workflows/node-testing-workflow.yaml index 5f1b358..4a2a519 100644 --- a/.github/workflows/node-testing-workflow.yaml +++ b/.github/workflows/node-testing-workflow.yaml @@ -34,27 +34,11 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 - mysql: - image: mysql:5.7 - env: - MYSQL_ROOT_PASSWORD: '1234' # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - name: Build and push image + uses: totango/shared-github-actions/.github/actions/testing@testing + id: image with: - persist-credentials: false - - name: setup node - uses: actions/setup-node@master - with: - node-version: ${{ inputs.node_v }} - - # install application dependencies - - uses: c-hive/gha-npm-cache@v1 - - name: Install Dependencies - run: npm install - - name: Run tests - env: - REDIS_URL: 'redis' - run: | - env IS_LOCAL_LOG=true npm run test \ No newline at end of file + node_v: ${{ inputs.node_v }} + npm_token: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From 96dd24d1927ab6343f0f9f78f8331bcf1b3fbb6f Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Thu, 23 Jun 2022 12:57:14 +0300 Subject: [PATCH 3/8] Integration tests using real db --- .github/actions/testing/action.yml | 38 +++++++++---------- .../node-testing-with-dbs-workflow.yaml | 3 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/actions/testing/action.yml b/.github/actions/testing/action.yml index 06e9473..e3a07be 100644 --- a/.github/actions/testing/action.yml +++ b/.github/actions/testing/action.yml @@ -17,23 +17,23 @@ inputs: runs: using: "composite" - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - with: - persist-credentials: false - - name: setup node - uses: actions/setup-node@master - with: - node-version: ${{ inputs.node_v }} + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + with: + persist-credentials: false + - name: setup node + uses: actions/setup-node@master + with: + node-version: ${{ inputs.node_v }} - # install application dependencies - - uses: c-hive/gha-npm-cache@v1 - - name: Install Dependencies - run: npm install - - name: Run tests - env: - REDIS_URL: ${{ inputs.redis_url }} - DB_URL: ${{ inputs.db_url }} - run: | - env IS_LOCAL_LOG=true npm run test \ No newline at end of file + # install application dependencies + - uses: c-hive/gha-npm-cache@v1 + - name: Install Dependencies + run: npm install + - name: Run tests + env: + REDIS_URL: ${{ inputs.redis_url }} + DB_URL: ${{ inputs.db_url }} + run: | + env IS_LOCAL_LOG=true npm run test \ No newline at end of file diff --git a/.github/workflows/node-testing-with-dbs-workflow.yaml b/.github/workflows/node-testing-with-dbs-workflow.yaml index 90a96e7..23d595b 100644 --- a/.github/workflows/node-testing-with-dbs-workflow.yaml +++ b/.github/workflows/node-testing-with-dbs-workflow.yaml @@ -1,4 +1,4 @@ -name: Node testing workflow +name: Node testing with DB and Redis workflow on: workflow_call: @@ -14,6 +14,7 @@ env: ## Sets environment variable NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_OPTIONS: "--max-old-space-size=4096" + jobs: testing: # The type of runner that the job will run on From 8a36aba054f84169b89e3b4ba8ec5417683940cc Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Thu, 23 Jun 2022 13:12:04 +0300 Subject: [PATCH 4/8] Update action.yml --- .github/actions/testing/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/testing/action.yml b/.github/actions/testing/action.yml index e3a07be..32ef0f4 100644 --- a/.github/actions/testing/action.yml +++ b/.github/actions/testing/action.yml @@ -18,7 +18,7 @@ inputs: runs: using: "composite" steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 with: persist-credentials: false From 96cb18171509b83d4e2146dd64656b9cfd7e6a40 Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Thu, 23 Jun 2022 14:47:24 +0300 Subject: [PATCH 5/8] Update action.yml --- .github/actions/testing/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/testing/action.yml b/.github/actions/testing/action.yml index 32ef0f4..2d4e225 100644 --- a/.github/actions/testing/action.yml +++ b/.github/actions/testing/action.yml @@ -30,8 +30,10 @@ runs: # install application dependencies - uses: c-hive/gha-npm-cache@v1 - name: Install Dependencies + shell: bash run: npm install - name: Run tests + shell: bash env: REDIS_URL: ${{ inputs.redis_url }} DB_URL: ${{ inputs.db_url }} From 644eb1f335f9491b2666dcccb7577e6365d16fff Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Sun, 26 Jun 2022 10:08:50 +0300 Subject: [PATCH 6/8] APP-23838: Integration tests using real db --- .github/workflows/node-testing-with-dbs-workflow.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-testing-with-dbs-workflow.yaml b/.github/workflows/node-testing-with-dbs-workflow.yaml index 23d595b..0b2c55a 100644 --- a/.github/workflows/node-testing-with-dbs-workflow.yaml +++ b/.github/workflows/node-testing-with-dbs-workflow.yaml @@ -47,4 +47,5 @@ jobs: id: image with: node_v: ${{ inputs.node_v }} - npm_token: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + npm_token: ${{ secrets.NPM_TOKEN }} + db_url: mysql \ No newline at end of file From c0d9ae9b8e1105fea5a18bdd2833b85d8a9ecdd6 Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Tue, 28 Jun 2022 09:50:51 +0300 Subject: [PATCH 7/8] Rename testing action --- .github/workflows/node-testing-with-dbs-workflow.yaml | 4 ++-- .github/workflows/node-testing-workflow.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node-testing-with-dbs-workflow.yaml b/.github/workflows/node-testing-with-dbs-workflow.yaml index 0b2c55a..66813db 100644 --- a/.github/workflows/node-testing-with-dbs-workflow.yaml +++ b/.github/workflows/node-testing-with-dbs-workflow.yaml @@ -42,8 +42,8 @@ jobs: MYSQL_ROOT_PASSWORD: '1234' # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Build and push image - uses: totango/shared-github-actions/.github/actions/testing@add-testing-workflow-mysql + - name: Testing + uses: totango/shared-github-actions/.github/actions/testing@main id: image with: node_v: ${{ inputs.node_v }} diff --git a/.github/workflows/node-testing-workflow.yaml b/.github/workflows/node-testing-workflow.yaml index 4a2a519..70f5801 100644 --- a/.github/workflows/node-testing-workflow.yaml +++ b/.github/workflows/node-testing-workflow.yaml @@ -36,8 +36,8 @@ jobs: --health-retries 5 # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Build and push image - uses: totango/shared-github-actions/.github/actions/testing@testing + - name: Testing + uses: totango/shared-github-actions/.github/actions/testing@main id: image with: node_v: ${{ inputs.node_v }} From c6162776b717f2c17be3b40a31bdc2c33ccbabd6 Mon Sep 17 00:00:00 2001 From: PeshiTotango Date: Tue, 28 Jun 2022 13:16:34 +0300 Subject: [PATCH 8/8] add redis_url --- .github/workflows/node-testing-with-dbs-workflow.yaml | 3 ++- .github/workflows/node-testing-workflow.yaml | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/node-testing-with-dbs-workflow.yaml b/.github/workflows/node-testing-with-dbs-workflow.yaml index 66813db..e4dd428 100644 --- a/.github/workflows/node-testing-with-dbs-workflow.yaml +++ b/.github/workflows/node-testing-with-dbs-workflow.yaml @@ -48,4 +48,5 @@ jobs: with: node_v: ${{ inputs.node_v }} npm_token: ${{ secrets.NPM_TOKEN }} - db_url: mysql \ No newline at end of file + db_url: mysql + redis_url: redis \ No newline at end of file diff --git a/.github/workflows/node-testing-workflow.yaml b/.github/workflows/node-testing-workflow.yaml index 70f5801..b4b783b 100644 --- a/.github/workflows/node-testing-workflow.yaml +++ b/.github/workflows/node-testing-workflow.yaml @@ -23,17 +23,6 @@ jobs: container: node:${{ inputs.node_v }} - # Service containers to add` - services: - # Label used to access the service container - redis: - image: redis - # Set health checks to wait until redis has started - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Testing