Call-for-Code-for-Racial-Justice / Five-Fifths-Voter

Five Fifths Voter is a web application tool designed to enable and empower Black people and others to exercise their right to vote by ensuring their voice is heard
Apache License 2.0
67 stars 37 forks source link

Adding ci/cd for ui and services blue version #304

Closed upkarlidder closed 2 years ago

upkarlidder commented 2 years ago

Signed-off-by: Upkar Lidder ulidder@us.ibm.com

Contributes to #272

What did you do?

Added ci/cd action for ui and services

Why did you do it?

Automate ci/cd

How have you tested it?

Yes, tested locally with act

Were docs updated if needed?

Type of change

Checklist:

upkarlidder commented 2 years ago

@davidnixon I added blue manifest file. Once we get the blue server working, we can replace with a single manifest file and two value files, one for blue and one for prod.

There are two jobs in the workflow. One called deploy-ui and the second named deploy-services. Every push to main branch is deployed to the blue server and only releases will get deployed to the prod server. The release trigger does not do anything right now. I waned to first ensure blue one works first.

The ui works fine. The server install is timing out even though the timeout is 360 mins on GitHub free plan. I am investigating.

Please take a look at the code when you get a chance.

upkarlidder commented 2 years ago

Ah, the error was from cloudant vcap creds. I did not manually link a cloudant service with the service app. This should not be a problem in the blue server. So I think I am done for now. Please review the code when you get a chance.

@davidnixon @GeraldMit

   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR /home/vcap/deps/1/node_modules/@cloudant/cloudant/lib/reconfigure.js:83
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR       throw new Error('Missing Cloudant service in vcapServices');
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR       ^
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR Error: Missing Cloudant service in vcapServices
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at module.exports (/home/vcap/deps/1/node_modules/@cloudant/cloudant/lib/reconfigure.js:83:13)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Cloudant (/home/vcap/deps/1/node_modules/@cloudant/cloudant/cloudant.js:51:15)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Object.<anonymous> (/home/vcap/app/data/cacheDb.js:26:18)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Module._compile (internal/modules/cjs/loader.js:1085:14)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Module.load (internal/modules/cjs/loader.js:950:32)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Module.require (internal/modules/cjs/loader.js:974:19)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at require (internal/modules/cjs/helpers.js:93:18)
   2021-11-18T21:34:32.93-0800 [APP/PROC/WEB/0] ERR     at Object.<anonymous> (/home/vcap/app/routes/earlyvoting/ga.js:4:15)
   2021-11-18T21:34:32.97-0800 [APP/PROC/WEB/0] ERR error Command failed with exit code 1.
   2021-11-18T21:34:32.97-0800 [APP/PROC/WEB/0] OUT info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
   2021-11-18T21:34:33.06-0800 [APP/PROC/WEB/0] OUT Exit status 1
   2021-11-18T21:34:33.07-0800 [CELL/SSHD/0] OUT Exit status 0
   2021-11-18T21:34:38.66-0800 [CELL/0] OUT Cell d41d182a-f34a-45d4-b42f-8c756349e979 stopping instance 4c88da11-375a-4e36-529b-7e03
   2021-11-18T21:34:38.66-0800 [CELL/0] OUT Cell d41d182a-f34a-45d4-b42f-8c756349e979 destroying container for instance 4c88da11-375a-4e36-529b-7e03
   2021-11-18T21:34:38.73-0800 [API/3] OUT Process has crashed with type: "web"
   2021-11-18T21:34:38.78-0800 [API/3] OUT App instance exited with guid 02ceaaa4-ffc8-43d0-bf7a-1ce28d35ada8 payload: {"instance"=>"4c88da11-375a-4e36-529b-7e03", "index"=>0, "cell_id"=>"d41d182a-f34a-45d4-b42f-8c756349e979", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 1", "crash_count"=>3, "crash_timestamp"=>1637300078654732549, "version"=>"b93473f7-2d6d-4e9e-bce0-bcb43d752307"}
   2021-11-18T21:34:39.24-0800 [PROXY/0] OUT Exit status 137
   2021-11-18T21:34:44.41-0800 [CELL/0] OUT Cell d41d182a-f34a-45d4-b42f-8c756349e979 successfully destroyed container for instance 4c88da11-375a-4e36-529b-7e03
davidnixon commented 2 years ago

@upkarlidder This all looks right to me. Can you post here the command line you are using to test locally? I don't see how services/blue.yml or ui/blue.yml are used.

Also, is it still timing out?

upkarlidder commented 2 years ago

You can use act to test "locally". It will still deploy to the environment defined by the secrets. I have a deploy.secrets that I pass in with the following commands:

act -j deploy-services --secret-file ./.github/workflows/deploy.secrets

deploy.secrets:

BLUE_IBM_CLOUD_API_KEY=
BLUE_IBM_CLOUD_CF_API=
BLUE_IBM_CLOUD_CF_ORG=
BLUE_IBM_CLOUD_CF_SPACE=

BLUE_APP_VARS_FILE=
BLUE_IBM_MANIFEST_FILE=

PROD_APP_VARS_FILE=
PROD_IBM_MANIFEST_FILE=

The blue files are used in the action in this section:

echo "APP_VARS_FILE=${{ secrets.BLUE_APP_VARS_FILE }}" >> $GITHUB_ENV

and

uses: IBM/cloudfoundry-deploy@master
        with:
          IBM_CLOUD_API_KEY: $IBM_CLOUD_API_KEY
          IBM_CLOUD_CF_API: $IBM_CLOUD_CF_API
          IBM_CLOUD_CF_ORG: $IBM_CLOUD_CF_ORG
          IBM_CLOUD_CF_SPACE: $IBM_CLOUD_CF_SPACE
          APP_MANIFEST_FILE: $IBM_MANIFEST_FILE
          APP_VARS_FILE: $APP_VARS_FILE

and the following variables:

BLUE_APP_VARS_FILE="blue.yml"
BLUE_IBM_MANIFEST_FILE="manifest-blue.yml"
upkarlidder commented 2 years ago

is it still timing out?

Yes, it still times out in my cloud environment. I think we can run it with the blue server creds after you merge and debug there? It should not time out for not finding vcap services.