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

Merge latest from master #22366

Merged
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
26 changes: 21 additions & 5 deletions .github/workflows/ecr-login.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,47 @@ on:
# Every 6 hours, the password validity is 12 hours
schedule:
- cron: '0 */6 * * *'

permissions:
id-token: write
contents: read

jobs:
login:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS Credentials
id: acquire-credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-gov-west-1
role-to-assume: ${{ secrets.AWS_ROLE }}
output-credentials: true

- name: retrieve ecr password and store as secret
if: steps.acquire-credentials.outcome == 'success'
run: |
pip3 install -r .github/workflows/requirements.txt
python3 .github/workflows/ecr_password_updater.py
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ steps.acquire-credentials.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.acquire-credentials.outputs.aws-secret-access-key }}
AWS_DEFAULT_REGION: us-gov-west-1
GH_API_ACCESS_TOKEN: ${{ secrets.GH_API_ACCESS_TOKEN }}
# This 'test' job is usefull for fast debugging

# This 'test' job is useful for fast debugging
test:
needs: login
runs-on: ubuntu-latest
timeout-minutes: 1
container:
image: 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
image: 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
credentials:
username: AWS
# Here is the password retrieved as a secret that is set by the `login` job
password: ${{ secrets.ECR_PASSWORD }}
password: ${{ secrets.VAEC_ECR_PASSWORD }}
steps:
- run: echo "Inside a container pulled from ECR!!"
2 changes: 1 addition & 1 deletion .github/workflows/ecr_password_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_ecr_password() -> str:

password = get_ecr_password()
encrypted_password = encrypt(public_key_value, password)
update_password = requests.put('https://api.github.com/repos/department-of-veterans-affairs/caseflow/actions/secrets/ECR_PASSWORD',
update_password = requests.put('https://api.github.com/repos/department-of-veterans-affairs/caseflow/actions/secrets/VAEC_ECR_PASSWORD',
headers={'Accept': 'application/vnd.github.v3+json',
'Authorization': 'token ' + os.environ['GH_API_ACCESS_TOKEN']},
data=json.dumps({'encrypted_value': encrypted_password, 'key_id': public_key_id,
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
- 6379:6379

facols_db:
image: 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/facols:latest
image: 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com/facols:latest
credentials:
username: AWS
password: ${{ secrets.ECR_PASSWORD }}
password: ${{ secrets.VAEC_ECR_PASSWORD }}
ports:
- 1521:1521

Expand All @@ -52,11 +52,11 @@ jobs:
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

container:
image: 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
image: 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
options: --privileged # Necessary for Rspec to run with our configuration within GHA
credentials:
username: AWS
password: ${{ secrets.ECR_PASSWORD }}
password: ${{ secrets.VAEC_ECR_PASSWORD }}

env:
DBUS_SESSION_BUS_ADDRESS: /dev/null
Expand Down Expand Up @@ -266,10 +266,10 @@ jobs:
if: true
runs-on: ubuntu-latest
container:
image: 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
image: 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
credentials:
username: AWS
password: ${{ secrets.ECR_PASSWORD }}
password: ${{ secrets.VAEC_ECR_PASSWORD }}
env:
DBUS_SESSION_BUS_ADDRESS: /dev/null
RAILS_ENV: test
Expand Down Expand Up @@ -328,10 +328,10 @@ jobs:
if: true
runs-on: ubuntu-latest
container:
image: 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
image: 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers
credentials:
username: AWS
password: ${{ secrets.ECR_PASSWORD }}
password: ${{ secrets.VAEC_ECR_PASSWORD }}

steps:
- name: Checkout
Expand Down
10 changes: 9 additions & 1 deletion app/queries/hearing_request_distribution_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def not_genpop_appeals
ama_non_aod_hearing_query.or(ama_aod_hearing_query).uniq
end

# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def only_genpop_appeals
ama_non_aod_hearing_query = generate_ama_only_genpop_non_aod_hearing_query(base_relation)
ama_aod_hearing_query = generate_ama_only_genpop_aod_hearing_query(base_relation)
Expand All @@ -79,9 +80,16 @@ def only_genpop_appeals
# the base result is doing an inner join with hearings so it isn't retrieving any appeals that have no hearings
# yet, so we add with_no_hearings to retrieve those appeals
no_hearings_or_no_held_hearings = with_no_hearings.or(with_no_held_hearings)
no_hearings_or_only_no_held_hearings = []
no_hearings_or_no_held_hearings.each do |appeal|
if appeal.hearings.blank? || appeal.hearings.pluck(:disposition).exclude?("held")
no_hearings_or_only_no_held_hearings << appeal
end
end

[*result, *no_hearings_or_no_held_hearings].uniq
[*result, *no_hearings_or_only_no_held_hearings].uniq
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength

def generate_ama_not_genpop_non_aod_hearing_query(base_relation)
query =
Expand Down
6 changes: 3 additions & 3 deletions ci-bin/circle_docker_container/build_and_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ fi

rm instant-client-12-1.tar.gz

aws ecr get-login-password --region us-gov-west-1 | docker login --username AWS --password-stdin 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com
aws ecr get-login-password --region us-gov-west-1 | docker login --username AWS --password-stdin 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com

docker build -t cimg-ruby .
# In case we modify this image and keep the same ruby version, we should use a different tag (i.e. image digest)
docker tag cimg-ruby:latest 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/cimg-ruby:2.7.3-browsers
if docker push 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/cimg-ruby:2.7.3-browsers ; then
docker tag cimg-ruby:latest 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com/cimg-ruby:2.7.3-browsers
if docker push 065403089830.dkr.ecr.us-gov-west-1.amazonaws.com/cimg-ruby:2.7.3-browsers ; then
echo 'Success the latest docker image has been pushed.'
else
echo 'Failed. You likely need to sign in with MFA https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/'
Expand Down
66 changes: 59 additions & 7 deletions client/test/app/caseDistribution/pages/CaseDistributionApp.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import React from 'react';
import CaseDistributionApp from 'app/caseDistribution/pages/CaseDistributionApp';
import {
history as leverHistory,
mockAffinityDaysLevers,
mockBatchLevers,
mockDocketDistributionPriorLevers,
mockDocketTimeGoalsLevers,
mockStaticLevers
} from '../../../data/adminCaseDistributionLevers';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import rootReducer from 'app/caseDistribution/reducers/root';
import thunk from 'redux-thunk';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';

describe('render Case Distribution Application', () => {

Expand All @@ -13,26 +22,26 @@ describe('render Case Distribution Application', () => {
applyMiddleware(thunk));

let testLevers = {
static: [],
batch: [],
affinity: [],
docket_distribution_prior: [],
docket_time_goal: []
static: mockStaticLevers,
batch: mockBatchLevers,
affinity: mockAffinityDaysLevers,
docket_distribution_prior: mockDocketDistributionPriorLevers,
docket_time_goal: mockDocketTimeGoalsLevers
};

afterEach(() => {
jest.clearAllMocks();
});

it('renders Case Distribution App', () => {
it('renders Case Distribution App as editable for an admin', () => {
const store = getStore();

let wrapper = mount(
<Provider store={store}>
<CaseDistributionApp
acdLeversForStore={testLevers}
acd_levers={testLevers}
acd_history={[]}
acd_history={leverHistory}
user_is_an_acd_admin
/>
</Provider>
Expand All @@ -43,7 +52,50 @@ describe('render Case Distribution Application', () => {
expect(wrapper.find('#lever-history-table').exists()).toBeTruthy();
expect(wrapper.find('.inactive-data-content').exists()).toBeTruthy();
expect(wrapper.find('.lever-content').exists()).toBeTruthy();
// the buttons and inputs will only render for admin users
expect(wrapper.find('button').exists()).toBe(true);
expect(wrapper.find('input').length > 0).toBe(true);
});

it('renders Case Distribution App as read-only for a non admin', () => {
const store = getStore();

let wrapper = mount(
<Provider store={store}>
<CaseDistributionApp
acdLeversForStore={testLevers}
acd_levers={testLevers}
acd_history={leverHistory}
user_is_an_acd_admin={false}
/>
</Provider>
);

wrapper.update();

expect(wrapper.find('#lever-history-table').exists()).toBeTruthy();
expect(wrapper.find('.inactive-data-content').exists()).toBeTruthy();
expect(wrapper.find('.lever-content').exists()).toBeTruthy();
// the buttons and inputs will only render for admin users
expect(wrapper.find('button').exists()).toBe(false);
expect(wrapper.find('input').length === 0).toBe(true);
});

it('matches snapshot', () => {
const store = getStore();

const { container } = render(
<Provider store={store}>
<CaseDistributionApp
acdLeversForStore={testLevers}
acd_levers={testLevers}
acd_history={leverHistory}
user_is_an_acd_admin
/>
</Provider>
);

expect(container).toMatchSnapshot();
});
});

Loading
Loading