From ec2dbf74e40de70905d09340157f1a6eb03700dd Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 31 Jul 2023 13:54:54 -0500 Subject: [PATCH 1/4] add exception handling to audit remove script --- .../audit/remove_caseflow_audit_schema.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/db/scripts/audit/remove_caseflow_audit_schema.rb b/db/scripts/audit/remove_caseflow_audit_schema.rb index 344617e8aa8..b1a0cb7ea5e 100644 --- a/db/scripts/audit/remove_caseflow_audit_schema.rb +++ b/db/scripts/audit/remove_caseflow_audit_schema.rb @@ -2,8 +2,16 @@ require "pg" -conn = CaseflowRecord.connection -conn.execute( - "drop schema IF EXISTS caseflow_audit CASCADE;" -) -conn.close +begin + conn = CaseflowRecord.connection + conn.execute( + "drop schema IF EXISTS caseflow_audit CASCADE;" + ) + conn.close +rescue ActiveRecord::NoDatabaseError => error + if error.message.include?('database "caseflow_certification_development" does not exist') + puts "Database caseflow_certification_development does not exist; skipping make audit-remove" + else + raise error + end +end From 7d00f3c7be48ffcbc252b6fb7c833cb3610ea9c3 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 31 Jul 2023 15:56:12 -0500 Subject: [PATCH 2/4] test update to yarn dependency cache keys --- .github/workflows/workflow.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 622314d76f0..f68baec3cb3 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -80,13 +80,12 @@ jobs: id: cache-yarn-cache uses: actions/cache/restore@v3 with: - key: dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }} + key: node-dependencies path: | ~/.cache/yarn public/assets tmp/cache/assets/sprockets - restore-keys: - dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }} + restore-keys: node-dependencies - name: Install Node Dependencies run: ./ci-bin/capture-log "cd client && yarn install --frozen-lockfile" @@ -95,7 +94,7 @@ jobs: if: steps.cache-yarn-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v3 with: - key: dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }} + key: node-dependencies path: | ~/.cache/yarn public/assets From f1bb1cccf6aada5f410d9a96d97bd9af0f1cb780 Mon Sep 17 00:00:00 2001 From: Craig Reese <109101548+craigrva@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:04:33 -0500 Subject: [PATCH 3/4] Craig/test yarn cache (#19096) modify .github/workflows/workflow.yml --- .github/workflows/workflow.yml | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index f68baec3cb3..d5b2fe6a3b1 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -76,29 +76,38 @@ jobs: steps: - uses: actions/checkout@v3 + # If we don't explicitly set this, the runner doesn't find the path when trying to save the cache + - name: Set yarn cache directory + id: set-yarn-cache-dir + run: mkdir -p ~/.cache/yarn && yarn config set cache-folder ~/.cache/yarn + - name: restore yarn cache id: cache-yarn-cache uses: actions/cache/restore@v3 with: - key: node-dependencies + # hashFiles('client/yarn.lock') will use a unique cache based on dependencies so that we don't + # create a cache for each target branch + key: yarn-cache-${{ hashFiles('client/yarn.lock') }} + # We are including node_modules because most of the time is used to build the dependencies path: | + node_modules + client/node_modules ~/.cache/yarn - public/assets - tmp/cache/assets/sprockets - restore-keys: node-dependencies + restore-keys: yarn-cache-${{ hashFiles('client/yarn.lock') }} + # We run yarn install after loading the cache to update any dependencies if their version is different - name: Install Node Dependencies - run: ./ci-bin/capture-log "cd client && yarn install --frozen-lockfile" + run: ./ci-bin/capture-log "cd client && yarn install --frozen-lockfile --prefer-offline" - name: Save Yarn Cache if: steps.cache-yarn-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v3 with: - key: node-dependencies + key: yarn-cache-${{ hashFiles('client/yarn.lock') }} path: | + node_modules + client/node_modules ~/.cache/yarn - public/assets - tmp/cache/assets/sprockets - name: setup testfiles directory run: ./ci-bin/capture-log "mkdir -p tmp/testfiles" @@ -177,9 +186,11 @@ jobs: ./ci-bin/capture-log "DB=etl bundle exec rake db:create db:schema:load db:migrate" ./ci-bin/capture-log "bundle exec rake db:create db:schema:load db:migrate" - - name: make seed-dbs + # We don't want to seed DBs here because DatabaseCleaner just truncates it anyway. The setup_vacols + # rake task needs to be run because it adds data to two tables that are ignored by DBCleaner + - name: Seed databases run: | - ./ci-bin/capture-log "make -f Makefile.example seed-dbs" + ./ci-bin/capture-log "bundle exec rake spec:setup_vacols" - name: Assets Precompile run: | From a5ae986807424f333aa9cbdb62089384d1e2b5ac Mon Sep 17 00:00:00 2001 From: Craig Reese <109101548+craigrva@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:32:50 -0500 Subject: [PATCH 4/4] exclude db/scripts in codeclimate (#19103) --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index a8e4f40fa31..bc142b4e9d5 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -116,6 +116,7 @@ plugins: exclude_patterns: - 'db/schema.rb' - 'db/seeds.rb' + - 'db/scripts/*' - 'node_modules/**/*' - 'app/mappers/zip_code_to_lat_lng_mapper.rb' - 'tmp/**/*'