From b42aab687001a0483f2df95823d4b7b47c2b800e Mon Sep 17 00:00:00 2001 From: Diego Manzanarez Date: Tue, 19 Jul 2022 13:12:24 -0500 Subject: [PATCH 1/7] Added workflow and gcp JS client library script with package json --- .../gql-perf-arch-github_workflow.yml | 70 +++++++++++++++++++ google_cloud_http_target_task.js | 63 +++++++++++++++++ package.json | 23 ++++++ 3 files changed, 156 insertions(+) create mode 100644 .github/workflows/gql-perf-arch-github_workflow.yml create mode 100644 google_cloud_http_target_task.js create mode 100644 package.json diff --git a/.github/workflows/gql-perf-arch-github_workflow.yml b/.github/workflows/gql-perf-arch-github_workflow.yml new file mode 100644 index 0000000000..e01cfe0947 --- /dev/null +++ b/.github/workflows/gql-perf-arch-github_workflow.yml @@ -0,0 +1,70 @@ +name: gql-perf-arch-github_workflow +on: + push: + branches: + - master + workflow_dispatch: + inputs: + COMMIT_HASH_INPUT: + description: 'Commit hash' + required: true + CLASSES_TO_EXECUTE_INPUT: + description: 'Classes to test' + required: false + PULL_REQUEST_NUMBER_INPUT: + description: 'Pull request number' + required: false +env: + #Actions secrets (keys) + PROJECT_ID: ${{ secrets.PROJECT_ID }} + QUEUE_ID: ${{ secrets.QUEUE_ID }} + LOCATION: ${{ secrets.LOCATION }} + WORKFLOW_URL: ${{ secrets.WORKFLOW_URL }} + SERVICE_ACCOUNT_EMAIL: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} + #Payload variables + COMMIT_HASH: ${{ (github.sha) }} + CLASSES: ${{ (github.event.inputs.CLASSES_TO_EXECUTE_INPUT) }} + PULL_REQUEST_NUMBER: ${{ (github.event.inputs.PULL_REQUEST_NUMBER_INPUT) }} +jobs: + push_action: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '14' + - run: npm install + - run: npm i yenv + - run: npm i uuid + + - id: 'auth' + name: 'Authenticate to Google Cloud' + uses: google-github-actions/auth@v0.4.0 + with: + credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + + - name: Execute JS script + run: node google_cloud_http_target_task.js + + workflow_dispatch_action: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '14' + - run: npm install + - run: npm i yenv + - run: npm install uuid + - run: echo "COMMIT_HASH=${{ (github.event.inputs.COMMIT_HASH_INPUT) }} " >> $GITHUB_ENV + + - id: 'auth' + name: 'Authenticate to Google Cloud' + uses: google-github-actions/auth@v0.4.0 + with: + credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + + - name: Execute JS script + run: node google_cloud_http_target_task.js diff --git a/google_cloud_http_target_task.js b/google_cloud_http_target_task.js new file mode 100644 index 0000000000..878f08ac4f --- /dev/null +++ b/google_cloud_http_target_task.js @@ -0,0 +1,63 @@ +const {CloudTasksClient} = require('@google-cloud/tasks'); +const yenv = require('yenv') +const { v4: uuidv4 } = require('uuid'); +const fs = require('fs') +const os = require('os'); + +// Parse 'gql-perf-arch-github_workflow.yml' file +const parsedDocument = yenv('.github/workflows/gql-perf-arch-github_workflow.yml') + +// Instantiate a client +const client = new CloudTasksClient(); + +// Payload variables +const jobId = String(uuidv4()); +const commitHash = parsedDocument.COMMIT_HASH; +const classes = parsedDocument.CLASSES; +const pullRequestNumber = parsedDocument.PULL_REQUEST_NUMBER; + + +async function createHttpTaskWithToken() { + // Actions secrets (keys) + const project = parsedDocument.PROJECT_ID; + const queue = parsedDocument.QUEUE_ID; + const location = parsedDocument.LOCATION; + const url = parsedDocument.WORKFLOW_URL; + const serviceAccountEmail = parsedDocument.SERVICE_ACCOUNT_EMAIL; + + // Construct payload + const payloadStructure = { + "jobId": jobId, + "commitHash": commitHash, + "classes": classes, + "pullRequest": pullRequestNumber, + } + //Format payload + const parsedPayload = JSON.stringify(JSON.stringify(payloadStructure)); + const payload = `{"argument": ${parsedPayload}}`; + + console.log(`Payload: ${payload}`); + + // Construct the fully qualified queue name + const parent = client.queuePath(project, location, queue); + + // Construct task with oauth authorization + const task = { + httpRequest: { + httpMethod: 'POST', + url, + oauthToken: { + serviceAccountEmail, + }, + body: Buffer.from(payload).toString('base64'), + }, + }; + + console.log(`Task: ${task}`); + const request = {parent: parent, task: task}; + const [response] = await client.createTask(request); + const name = response.name; + console.log(`Created task ${name}`); + console.log(`Your job id is: ${jobId}`); +} +createHttpTaskWithToken(); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000000..d5fec09971 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "appengine-cloudtasks", + "description": "Google App Engine Cloud Tasks example.", + "license": "Apache-2.0", + "author": "Google Inc.", + "private": true, + "engines": { + "node": ">=12.0.0" + }, + "files": [ + "*.js" + ], + "dependencies": { + "@google-cloud/tasks": "^3.0.0", + "body-parser": "^1.18.3", + "express": "^4.16.3" + }, + "devDependencies": { + "chai": "^4.2.0", + "mocha": "^8.0.0", + "uuid": "^8.0.0" + } +} From a5eb181c14e905bcb515b2e5868d99951a70c87b Mon Sep 17 00:00:00 2001 From: Diego Manzanarez Date: Wed, 20 Jul 2022 10:32:26 -0500 Subject: [PATCH 2/7] Refactored code --- .../google_cloud_http_target_task.js | 66 +++++++++++++++++++ .../gql-perf-arch-github_workflow.yml | 34 ++-------- google_cloud_http_target_task.js | 63 ------------------ package.json | 5 +- 4 files changed, 75 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/google_cloud_http_target_task.js delete mode 100644 google_cloud_http_target_task.js diff --git a/.github/workflows/google_cloud_http_target_task.js b/.github/workflows/google_cloud_http_target_task.js new file mode 100644 index 0000000000..fde292d77a --- /dev/null +++ b/.github/workflows/google_cloud_http_target_task.js @@ -0,0 +1,66 @@ +const { CloudTasksClient } = require('@google-cloud/tasks'); +const yenv = require('yenv') +const { v4: uuidv4 } = require('uuid'); + +const parsedDocument = yenv('.github/workflows/gql-perf-arch-github_workflow.yml') +const client = new CloudTasksClient(); + +const constructPayload = () => { + const jobId = String(uuidv4()); + const commitHash = parsedDocument.COMMIT_HASH; + const classes = parsedDocument.CLASSES; + const pullRequestNumber = parsedDocument.PULL_REQUEST_NUMBER; + + const payloadStructure = { + "jobId": jobId, + "commitHash": commitHash, + "classes": classes, + "pullRequest": pullRequestNumber, + } + return payloadStructure; +} + +const formatPayload = (payloadStructure) => { + const parsedPayload = JSON.stringify(JSON.stringify(payloadStructure)); + const payload = `{"argument": ${parsedPayload}}`; + console.log(`Payload: ${payload}`); + return payload; +} + +const constructTask = (serviceAccountEmail, payload, url) => { + const task = { + httpRequest: { + httpMethod: 'POST', + url, + oauthToken: { + serviceAccountEmail, + }, + body: Buffer.from(payload).toString('base64'), + }, + }; + return task; +} + +const createRequestBody = (payload) => { + const project = parsedDocument.PROJECT_ID; + const queue = parsedDocument.QUEUE_ID; + const location = parsedDocument.LOCATION; + const url = parsedDocument.WORKFLOW_URL; + const serviceAccountEmail = parsedDocument.SERVICE_ACCOUNT_EMAIL; + const requestBody = { + "fullyQualifiedQueueName": client.queuePath(project, location, queue), + "task": constructTask(serviceAccountEmail, payload, url) + } + return requestBody; +} + +async function createHttpTaskWithToken() { + const payloadStructure = constructPayload(); + const payload = formatPayload(payloadStructure); + const requestBody = createRequestBody(payload); + const request = { parent: requestBody.fullyQualifiedQueueName, task: requestBody.task }; + const [response] = await client.createTask(request); + const name = response.name; + console.log(`Created task ${name}`); +} +createHttpTaskWithToken(); diff --git a/.github/workflows/gql-perf-arch-github_workflow.yml b/.github/workflows/gql-perf-arch-github_workflow.yml index e01cfe0947..b2bd9ba135 100644 --- a/.github/workflows/gql-perf-arch-github_workflow.yml +++ b/.github/workflows/gql-perf-arch-github_workflow.yml @@ -2,7 +2,7 @@ name: gql-perf-arch-github_workflow on: push: branches: - - master + - main workflow_dispatch: inputs: COMMIT_HASH_INPUT: @@ -25,40 +25,20 @@ env: COMMIT_HASH: ${{ (github.sha) }} CLASSES: ${{ (github.event.inputs.CLASSES_TO_EXECUTE_INPUT) }} PULL_REQUEST_NUMBER: ${{ (github.event.inputs.PULL_REQUEST_NUMBER_INPUT) }} + jobs: - push_action: + execute_workflow: runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '14' - run: npm install - - run: npm i yenv - - run: npm i uuid - - - id: 'auth' - name: 'Authenticate to Google Cloud' - uses: google-github-actions/auth@v0.4.0 - with: - credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - - name: Execute JS script - run: node google_cloud_http_target_task.js - - workflow_dispatch_action: - runs-on: ubuntu-latest - if: ${{ github.event_name == 'workflow_dispatch' }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '14' - - run: npm install - - run: npm i yenv - - run: npm install uuid - - run: echo "COMMIT_HASH=${{ (github.event.inputs.COMMIT_HASH_INPUT) }} " >> $GITHUB_ENV + - name: Update COMMIT_HASH + if: ${{ github.event_name == 'workflow_dispatch' }} + run: echo "COMMIT_HASH=${{ (github.event.inputs.COMMIT_HASH_INPUT) }} " >> $GITHUB_ENV - id: 'auth' name: 'Authenticate to Google Cloud' @@ -67,4 +47,4 @@ jobs: credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - name: Execute JS script - run: node google_cloud_http_target_task.js + run: node .github/workflows/google_cloud_http_target_task.js diff --git a/google_cloud_http_target_task.js b/google_cloud_http_target_task.js deleted file mode 100644 index 878f08ac4f..0000000000 --- a/google_cloud_http_target_task.js +++ /dev/null @@ -1,63 +0,0 @@ -const {CloudTasksClient} = require('@google-cloud/tasks'); -const yenv = require('yenv') -const { v4: uuidv4 } = require('uuid'); -const fs = require('fs') -const os = require('os'); - -// Parse 'gql-perf-arch-github_workflow.yml' file -const parsedDocument = yenv('.github/workflows/gql-perf-arch-github_workflow.yml') - -// Instantiate a client -const client = new CloudTasksClient(); - -// Payload variables -const jobId = String(uuidv4()); -const commitHash = parsedDocument.COMMIT_HASH; -const classes = parsedDocument.CLASSES; -const pullRequestNumber = parsedDocument.PULL_REQUEST_NUMBER; - - -async function createHttpTaskWithToken() { - // Actions secrets (keys) - const project = parsedDocument.PROJECT_ID; - const queue = parsedDocument.QUEUE_ID; - const location = parsedDocument.LOCATION; - const url = parsedDocument.WORKFLOW_URL; - const serviceAccountEmail = parsedDocument.SERVICE_ACCOUNT_EMAIL; - - // Construct payload - const payloadStructure = { - "jobId": jobId, - "commitHash": commitHash, - "classes": classes, - "pullRequest": pullRequestNumber, - } - //Format payload - const parsedPayload = JSON.stringify(JSON.stringify(payloadStructure)); - const payload = `{"argument": ${parsedPayload}}`; - - console.log(`Payload: ${payload}`); - - // Construct the fully qualified queue name - const parent = client.queuePath(project, location, queue); - - // Construct task with oauth authorization - const task = { - httpRequest: { - httpMethod: 'POST', - url, - oauthToken: { - serviceAccountEmail, - }, - body: Buffer.from(payload).toString('base64'), - }, - }; - - console.log(`Task: ${task}`); - const request = {parent: parent, task: task}; - const [response] = await client.createTask(request); - const name = response.name; - console.log(`Created task ${name}`); - console.log(`Your job id is: ${jobId}`); -} -createHttpTaskWithToken(); \ No newline at end of file diff --git a/package.json b/package.json index d5fec09971..59317967a1 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,10 @@ "dependencies": { "@google-cloud/tasks": "^3.0.0", "body-parser": "^1.18.3", - "express": "^4.16.3" + "express": "^4.16.3", + "yenv": "^3.0.1" }, "devDependencies": { - "chai": "^4.2.0", - "mocha": "^8.0.0", "uuid": "^8.0.0" } } From 6a302e9b822c0169960a8a3a9baf4a0cde8ec39f Mon Sep 17 00:00:00 2001 From: Diego Manzanarez Date: Wed, 20 Jul 2022 11:40:38 -0500 Subject: [PATCH 3/7] Fixed branch field in yml file and dependencies in package json --- .github/workflows/gql-perf-arch-github_workflow.yml | 2 +- package.json | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gql-perf-arch-github_workflow.yml b/.github/workflows/gql-perf-arch-github_workflow.yml index b2bd9ba135..d910f79686 100644 --- a/.github/workflows/gql-perf-arch-github_workflow.yml +++ b/.github/workflows/gql-perf-arch-github_workflow.yml @@ -2,7 +2,7 @@ name: gql-perf-arch-github_workflow on: push: branches: - - main + - master workflow_dispatch: inputs: COMMIT_HASH_INPUT: diff --git a/package.json b/package.json index 59317967a1..90987a264a 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,7 @@ "@google-cloud/tasks": "^3.0.0", "body-parser": "^1.18.3", "express": "^4.16.3", - "yenv": "^3.0.1" - }, - "devDependencies": { + "yenv": "^3.0.1", "uuid": "^8.0.0" } } From a43e57bd1d2768326bad1d2b7015a81543c5f4a9 Mon Sep 17 00:00:00 2001 From: Diego Manzanarez Date: Fri, 22 Jul 2022 10:45:48 -0500 Subject: [PATCH 4/7] Added createRequest function and switched over to process env instead onf yenv --- ...loud_http_target_task.js => create_job.js} | 25 +++++++++++-------- ...ub_workflow.yml => invoke_test_runner.yml} | 7 +++--- 2 files changed, 17 insertions(+), 15 deletions(-) rename .github/workflows/{google_cloud_http_target_task.js => create_job.js} (75%) rename .github/workflows/{gql-perf-arch-github_workflow.yml => invoke_test_runner.yml} (91%) diff --git a/.github/workflows/google_cloud_http_target_task.js b/.github/workflows/create_job.js similarity index 75% rename from .github/workflows/google_cloud_http_target_task.js rename to .github/workflows/create_job.js index fde292d77a..5d9a7bdeae 100644 --- a/.github/workflows/google_cloud_http_target_task.js +++ b/.github/workflows/create_job.js @@ -1,15 +1,13 @@ const { CloudTasksClient } = require('@google-cloud/tasks'); -const yenv = require('yenv') const { v4: uuidv4 } = require('uuid'); -const parsedDocument = yenv('.github/workflows/gql-perf-arch-github_workflow.yml') const client = new CloudTasksClient(); const constructPayload = () => { const jobId = String(uuidv4()); - const commitHash = parsedDocument.COMMIT_HASH; - const classes = parsedDocument.CLASSES; - const pullRequestNumber = parsedDocument.PULL_REQUEST_NUMBER; + const commitHash = process.env.COMMIT_HASH; + const classes = process.env.CLASSES; + const pullRequestNumber = process.env.PULL_REQUEST_NUMBER; const payloadStructure = { "jobId": jobId, @@ -42,11 +40,11 @@ const constructTask = (serviceAccountEmail, payload, url) => { } const createRequestBody = (payload) => { - const project = parsedDocument.PROJECT_ID; - const queue = parsedDocument.QUEUE_ID; - const location = parsedDocument.LOCATION; - const url = parsedDocument.WORKFLOW_URL; - const serviceAccountEmail = parsedDocument.SERVICE_ACCOUNT_EMAIL; + const project = process.env.PROJECT_ID; + const queue = process.env.QUEUE_ID; + const location = process.env.LOCATION; + const url = process.env.WORKFLOW_URL + const serviceAccountEmail = process.env.SERVICE_ACCOUNT_EMAIL; const requestBody = { "fullyQualifiedQueueName": client.queuePath(project, location, queue), "task": constructTask(serviceAccountEmail, payload, url) @@ -54,11 +52,16 @@ const createRequestBody = (payload) => { return requestBody; } -async function createHttpTaskWithToken() { +const constructRequest = () => { const payloadStructure = constructPayload(); const payload = formatPayload(payloadStructure); const requestBody = createRequestBody(payload); const request = { parent: requestBody.fullyQualifiedQueueName, task: requestBody.task }; + return request; +} + +async function createHttpTaskWithToken() { + const request = constructRequest(); const [response] = await client.createTask(request); const name = response.name; console.log(`Created task ${name}`); diff --git a/.github/workflows/gql-perf-arch-github_workflow.yml b/.github/workflows/invoke_test_runner.yml similarity index 91% rename from .github/workflows/gql-perf-arch-github_workflow.yml rename to .github/workflows/invoke_test_runner.yml index d910f79686..d9e81e2cf2 100644 --- a/.github/workflows/gql-perf-arch-github_workflow.yml +++ b/.github/workflows/invoke_test_runner.yml @@ -1,4 +1,4 @@ -name: gql-perf-arch-github_workflow +name: invoke_test_runner on: push: branches: @@ -15,12 +15,11 @@ on: description: 'Pull request number' required: false env: - #Actions secrets (keys) PROJECT_ID: ${{ secrets.PROJECT_ID }} QUEUE_ID: ${{ secrets.QUEUE_ID }} LOCATION: ${{ secrets.LOCATION }} - WORKFLOW_URL: ${{ secrets.WORKFLOW_URL }} SERVICE_ACCOUNT_EMAIL: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} + WORKFLOW_URL: ${{ secrets.WORKFLOW_URL }} #Payload variables COMMIT_HASH: ${{ (github.sha) }} CLASSES: ${{ (github.event.inputs.CLASSES_TO_EXECUTE_INPUT) }} @@ -47,4 +46,4 @@ jobs: credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - name: Execute JS script - run: node .github/workflows/google_cloud_http_target_task.js + run: node .github/workflows/create_job.js From 84611561ffaf0a859016219de5814436cfd9b964 Mon Sep 17 00:00:00 2001 From: Diego Manzanarez Date: Tue, 9 Aug 2022 16:41:51 -0500 Subject: [PATCH 5/7] Added string to array function --- .github/workflows/create_job.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create_job.js b/.github/workflows/create_job.js index 5d9a7bdeae..444c816a0d 100644 --- a/.github/workflows/create_job.js +++ b/.github/workflows/create_job.js @@ -12,12 +12,18 @@ const constructPayload = () => { const payloadStructure = { "jobId": jobId, "commitHash": commitHash, - "classes": classes, + "classes": castClassesStringToArray(classes), "pullRequest": pullRequestNumber, } return payloadStructure; } +const castClassesStringToArray = (classes) => { + const classesArray = classes.split(','); + const timedClassesArray = classesArray.map(currentClass => currentClass.trim()); + return timedClassesArray; +} + const formatPayload = (payloadStructure) => { const parsedPayload = JSON.stringify(JSON.stringify(payloadStructure)); const payload = `{"argument": ${parsedPayload}}`; From e7ff81517afe6d752458e32aa143b0beb5f1f8c4 Mon Sep 17 00:00:00 2001 From: Diego Manzanarez Date: Tue, 9 Aug 2022 16:54:56 -0500 Subject: [PATCH 6/7] Fixed typos on string to array function --- .github/workflows/create_job.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create_job.js b/.github/workflows/create_job.js index 444c816a0d..7112ad32ef 100644 --- a/.github/workflows/create_job.js +++ b/.github/workflows/create_job.js @@ -12,16 +12,16 @@ const constructPayload = () => { const payloadStructure = { "jobId": jobId, "commitHash": commitHash, - "classes": castClassesStringToArray(classes), + "classes": convertClassesStringToArray(classes), "pullRequest": pullRequestNumber, } return payloadStructure; } -const castClassesStringToArray = (classes) => { +const convertClassesStringToArray = (classes) => { const classesArray = classes.split(','); - const timedClassesArray = classesArray.map(currentClass => currentClass.trim()); - return timedClassesArray; + const trimmedClassesArray = classesArray.map(currentClass => currentClass.trim()); + return trimmedClassesArray; } const formatPayload = (payloadStructure) => { From 03776d73d3448f5464daab0a848fb78cce641c1a Mon Sep 17 00:00:00 2001 From: Diego Manzanarez Date: Mon, 5 Sep 2022 18:15:34 -0500 Subject: [PATCH 7/7] Moved package json to workflows folder and removed unused dependencies --- .github/workflows/create_job.js | 6 ++++-- .github/workflows/invoke_test_runner.yml | 10 +++++++++- .github/workflows/package.json | 14 ++++++++++++++ package.json | 20 -------------------- 4 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/package.json delete mode 100644 package.json diff --git a/.github/workflows/create_job.js b/.github/workflows/create_job.js index 7112ad32ef..e14f39f828 100644 --- a/.github/workflows/create_job.js +++ b/.github/workflows/create_job.js @@ -6,14 +6,16 @@ const client = new CloudTasksClient(); const constructPayload = () => { const jobId = String(uuidv4()); const commitHash = process.env.COMMIT_HASH; + const branch = process.env.BRANCH; const classes = process.env.CLASSES; const pullRequestNumber = process.env.PULL_REQUEST_NUMBER; const payloadStructure = { "jobId": jobId, - "commitHash": commitHash, + "commitHash": commitHash.trim(), + "branch": branch.trim(), "classes": convertClassesStringToArray(classes), - "pullRequest": pullRequestNumber, + "pullRequest": pullRequestNumber.trim(), } return payloadStructure; } diff --git a/.github/workflows/invoke_test_runner.yml b/.github/workflows/invoke_test_runner.yml index d9e81e2cf2..0792700115 100644 --- a/.github/workflows/invoke_test_runner.yml +++ b/.github/workflows/invoke_test_runner.yml @@ -5,6 +5,9 @@ on: - master workflow_dispatch: inputs: + BRANCH_INPUT: + description: 'Branch' + required: true COMMIT_HASH_INPUT: description: 'Commit hash' required: true @@ -22,6 +25,7 @@ env: WORKFLOW_URL: ${{ secrets.WORKFLOW_URL }} #Payload variables COMMIT_HASH: ${{ (github.sha) }} + BRANCH: ${{ (github.ref_name) }} CLASSES: ${{ (github.event.inputs.CLASSES_TO_EXECUTE_INPUT) }} PULL_REQUEST_NUMBER: ${{ (github.event.inputs.PULL_REQUEST_NUMBER_INPUT) }} @@ -33,12 +37,16 @@ jobs: - uses: actions/setup-node@v3 with: node-version: '14' - - run: npm install + - run: npm install --prefix .github/workflows - name: Update COMMIT_HASH if: ${{ github.event_name == 'workflow_dispatch' }} run: echo "COMMIT_HASH=${{ (github.event.inputs.COMMIT_HASH_INPUT) }} " >> $GITHUB_ENV + - name: Update BRANCH + if: ${{ github.event_name == 'workflow_dispatch' }} + run: echo "BRANCH=${{ (github.event.inputs.BRANCH_INPUT) }} " >> $GITHUB_ENV + - id: 'auth' name: 'Authenticate to Google Cloud' uses: google-github-actions/auth@v0.4.0 diff --git a/.github/workflows/package.json b/.github/workflows/package.json new file mode 100644 index 0000000000..71ef804476 --- /dev/null +++ b/.github/workflows/package.json @@ -0,0 +1,14 @@ +{ + "name": "workflow-testrunner-tasksenqueuer", + "private": true, + "engines": { + "node": ">=12.0.0" + }, + "files": [ + "*.js" + ], + "dependencies": { + "@google-cloud/tasks": "^3.0.0", + "uuid": "^8.0.0" + } +} diff --git a/package.json b/package.json deleted file mode 100644 index 90987a264a..0000000000 --- a/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "appengine-cloudtasks", - "description": "Google App Engine Cloud Tasks example.", - "license": "Apache-2.0", - "author": "Google Inc.", - "private": true, - "engines": { - "node": ">=12.0.0" - }, - "files": [ - "*.js" - ], - "dependencies": { - "@google-cloud/tasks": "^3.0.0", - "body-parser": "^1.18.3", - "express": "^4.16.3", - "yenv": "^3.0.1", - "uuid": "^8.0.0" - } -}