Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix audit remove script and modify GHA workflow #19092

Merged
merged 5 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*'
Expand Down
32 changes: 21 additions & 11 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +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: dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }}
# 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:
dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }}
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: dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }}
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"
Expand Down Expand Up @@ -178,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: |
Expand Down
18 changes: 13 additions & 5 deletions db/scripts/audit/remove_caseflow_audit_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading