diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index e651a0d..defcf80 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -23,7 +23,8 @@ jobs: outputs: taggedImage: ${{ steps.prep.outputs.tagged_image }} tag: ${{ steps.prep.outputs.tag }} - registry: ${{ steps.prep.outputs.registry }} + registryEcr: ${{ steps.prep.outputs.registry_ecr }} + registryGhcr: ${{ steps.prep.outputs.registry_ghcr }} shortSha: ${{ steps.prep.outputs.short_sha}} branchName: ${{ steps.prep.outputs.branch_name }} latestTag: ${{ steps.prep.outputs.latest_tag }} @@ -38,10 +39,11 @@ jobs: SHORT_SHA=$(echo $GITHUB_SHA | head -c7) REPO=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}') TAG=${{ env.GIT_BRANCH_NAME }}-$(echo $GITHUB_SHA | head -c7) - IMAGE=public.ecr.aws/ideacrew/$REPO + IMAGE=ideacrew/$REPO echo ::set-output name=tagged_image::${IMAGE}:${TAG} echo ::set-output name=tag::${TAG} - echo ::set-output name=registry::public.ecr.aws + echo ::set-output name=registry_ecr::public.ecr.aws + echo ::set-output name=registry_ghcr::ghcr.io echo ::set-output name=short_sha::$SHORT_SHA echo ::set-output name=branch_name::${{ env.GIT_BRANCH_NAME }} echo ::set-output name=repository_name::$REPO @@ -84,6 +86,7 @@ jobs: uses: docker/setup-buildx-action@v1 with: install: true + version: v0.9.1 - name: Cache Docker layers uses: actions/cache@v2 @@ -112,10 +115,17 @@ jobs: - name: Login to Public ECR uses: docker/login-action@v1 with: - registry: ${{ needs.prep.outputs.registry }} + registry: ${{ needs.prep.outputs.registryEcr }} username: ${{ secrets.AWS_ACCESS_KEY_ID }} password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ${{ needs.prep.outputs.registryGhcr }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Image uses: docker/build-push-action@v2 with: @@ -130,7 +140,11 @@ jobs: push: ${{ github.event_name != 'pull_request' }} # create local image (for scanning) if it is a pull request load: ${{ github.event_name == 'pull_request' }} - tags: ${{ needs.prep.outputs.taggedImage }}, ${{ needs.prep.outputs.latestTag }} + tags: | + ${{ format('{0}/{1}', needs.prep.outputs.registryEcr, needs.prep.outputs.taggedImage) }} + ${{ format('{0}/{1}', needs.prep.outputs.registryEcr, needs.prep.outputs.latestTag) }} + ${{ format('{0}/{1}', needs.prep.outputs.registryGhcr, needs.prep.outputs.taggedImage) }} + ${{ format('{0}/{1}', needs.prep.outputs.registryGhcr, needs.prep.outputs.latestTag) }} cache-from: type=local,src=/tmp/.buildx-cache # Note the mode=max here # More: https://github.com/moby/buildkit#--export-cache-options @@ -144,14 +158,14 @@ jobs: id: scan uses: anchore/scan-action@main with: - image: ${{ needs.prep.outputs.taggedImage }} + image: ${{ format('{0}/{1}', needs.prep.outputs.registryGhcr, needs.prep.outputs.taggedImage) }} acs-report-enable: true fail-build: false severity-cutoff: critical - name: upload Anchore scan SARIF report if: github.event_name != 'pull_request' - uses: github/codeql-action/upload-sarif@v1 + uses: github/codeql-action/upload-sarif@v2 with: sarif_file: ${{ steps.scan.outputs.sarif }} @@ -164,12 +178,29 @@ jobs: if: github.event_name != 'pull_request' needs: [prep, build-and-upload-image] runs-on: ubuntu-latest + strategy: + matrix: + registry: ['public.ecr.aws', 'ghcr.io'] steps: - name: Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.16.0 + id: ic-slack + uses: slackapi/slack-github-action@v1 with: - channel-id: "docker-images-${{ needs.prep.outputs.repositoryName }}" - slack-message: "New image pushed: ${{ needs.prep.outputs.taggedImage }} built from on `${{ needs.prep.outputs.branchName }}`" + channel-id: 'docker-images-${{ needs.prep.outputs.repositoryName }}' + payload: | + { + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*${{ format('{0} image*:\n`{1}/{2}`', matrix.registry, matrix.registry, needs.prep.outputs.taggedImage) }}" + } + }, + { + "type": "divider" + } + ] + } env: SLACK_BOT_TOKEN: ${{ secrets.YELLR_BOT_TOKEN }} diff --git a/Gemfile.lock b/Gemfile.lock index 3fd0977..ba586c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/ideacrew/aca_entities.git - revision: e3c41158ef445a5a5cc1c6a1f99e58fbce655b32 + revision: 21261122695660b3c298a22f8a5b16a6c3f0e398 branch: trunk specs: aca_entities (0.10.0) @@ -11,6 +11,7 @@ GIT dry-types (~> 1.0) dry-validation (~> 1.2) iso_country_codes + json-schema nokogiri-happymapper oj (~> 3.11) rbnacl (~> 7.1) @@ -335,6 +336,8 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) + json-schema (4.0.0) + addressable (>= 2.8) kaminari (1.2.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.1) diff --git a/app/event_source/subscribers/families/notices/faa_totally_ineligible/faa_totally_ineligible_notice_subscriber.rb b/app/event_source/subscribers/families/notices/faa_totally_ineligible/faa_totally_ineligible_notice_subscriber.rb new file mode 100644 index 0000000..be0ea9e --- /dev/null +++ b/app/event_source/subscribers/families/notices/faa_totally_ineligible/faa_totally_ineligible_notice_subscriber.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Subscribers + module Families + module Notices + module FaaTotallyIneligible + # Subscriber will receive response payload from medicaid gateway and generate documents + class FaaTotallyIneligibleNoticeSubscriber + include EventSource::Logging + include ::EventSource::Subscriber[amqp: 'enroll.families.notices.faa_totally_ineligible_notice'] + + subscribe( + :on_enroll_families_notices_faa_totally_ineligible_notice + ) do |delivery_info, _metadata, response| + routing_key = delivery_info[:routing_key] + logger.info "Polypress: invoked FaaTotallyIneligibleNoticeSubscriber with delivery_info: #{delivery_info} routing_key: #{routing_key}" + + payload = JSON.parse(response, symbolize_names: true) + results = + MagiMedicaid::GenerateAndPublishEligibilityDocuments.new.call( + { payload: payload, event_key: routing_key } + ) + if results.all?(&:success) + logger.info "Polypress: FaaTotallyIneligibleNoticeSubscriber; acked for #{routing_key}" + else + results + .map(&:failure) + .compact + .each do |result| + errors = + if result.is_a?(String) + result + elsif result.failure.is_a?(String) + result.failure + else + result.failure.errors.to_h + end + logger.error( + "Polypress: FaaTotallyIneligibleNoticeSubscriber_error; + nacked due to:#{errors}; for routing_key: #{routing_key}, payload: #{payload}" + ) + end + end + ack(delivery_info.delivery_tag) + rescue StandardError, SystemStackError => e + logger.error( + "Polypress: FaaTotallyIneligibleNoticeSubscriber_error: nacked due to error: #{e}; backtrace: + #{e.backtrace}; for routing_key: #{routing_key}, response: #{response}" + ) + ack(delivery_info.delivery_tag) + end + end + end + end + end +end diff --git a/app/helpers/financial_application_helper.rb b/app/helpers/financial_application_helper.rb index c089749..5ebb26a 100644 --- a/app/helpers/financial_application_helper.rb +++ b/app/helpers/financial_application_helper.rb @@ -37,10 +37,10 @@ def addresses ] end - def family_member_reference + def family_member_reference(first_name) { :family_member_hbx_id => "100045", - :first_name => "Gerald", + :first_name => first_name, :last_name => "Rivers", :person_hbx_id => "1009501", :is_primary_family_member => true, @@ -56,9 +56,9 @@ def pregnancy_information } end - def attestation + def attestation(is_incarcerated) { - :is_incarcerated => false, + :is_incarcerated => is_incarcerated, :is_self_attested_disabled => true, :is_self_attested_blind => false } @@ -122,59 +122,64 @@ def medicaid_and_chip } end - # rubocop:disable Metrics/MethodLength def applicants [ - { - :name => { :first_name => "Gerald", :last_name => "Rivers" }, - :identifying_information => { :has_ssn => false }, - :demographic => demographic_info, - :attestation => attestation, - :is_primary_applicant => true, - :native_american_information => { :indian_tribe_member => false }, - :citizenship_immigration_status_information => citizenship_immigration_status_information, - :is_applying_coverage => true, - :family_member_reference => family_member_reference, - :person_hbx_id => "1009501", - :is_required_to_file_taxes => true, - :tax_filer_kind => "tax_filer", - :is_joint_tax_filing => true, - :is_claimed_as_tax_dependent => false, - :claimed_as_tax_dependent_by => nil, - :student => { :is_student => false }, - :is_refugee => false, - :is_trafficking_victim => false, - :foster_care => { :is_former_foster_care => false }, - :pregnancy_information => pregnancy_information, - :is_subject_to_five_year_bar => false, - :is_five_year_bar_met => false, - :has_job_income => true, - :has_self_employment_income => false, - :has_unemployment_income => false, - :has_other_income => false, - :has_deductions => false, - :has_enrolled_health_coverage => false, - :has_eligible_health_coverage => false, - :medicaid_and_chip => medicaid_and_chip, - :addresses => addresses, - :incomes => incomes, - :is_medicare_eligible => false, - :has_insurance => false, - :has_state_health_benefit => false, - :had_prior_insurance => false, - :age_of_applicant => 22, - :is_self_attested_long_term_care => false, - :hours_worked_per_week => 0, - :is_temporarily_out_of_state => false, - :is_claimed_as_dependent_by_non_applicant => false, - :benchmark_premium => benchmark_premium, - :is_homeless => false, - :mitc_income => mitc_income, - :mitc_relationships => [], - :local_mec_evidence => local_mec_evidence - } + create_applicant("Gerald", true, false), + create_applicant("Brock", false, true) ] end + + # rubocop:disable Metrics/MethodLength + def create_applicant(first_name, is_primary_aplicant, is_incarcerated) + { + :name => { :first_name => first_name, :last_name => "Rivers" }, + :identifying_information => { :has_ssn => false }, + :demographic => demographic_info, + :attestation => attestation(is_incarcerated), + :is_primary_applicant => is_primary_aplicant, + :native_american_information => { :indian_tribe_member => false }, + :citizenship_immigration_status_information => citizenship_immigration_status_information, + :is_applying_coverage => true, + :family_member_reference => family_member_reference(first_name), + :person_hbx_id => "1009501", + :is_required_to_file_taxes => true, + :tax_filer_kind => "tax_filer", + :is_joint_tax_filing => true, + :is_claimed_as_tax_dependent => false, + :claimed_as_tax_dependent_by => nil, + :student => { :is_student => false }, + :is_refugee => false, + :is_trafficking_victim => false, + :foster_care => { :is_former_foster_care => false }, + :pregnancy_information => pregnancy_information, + :is_subject_to_five_year_bar => false, + :is_five_year_bar_met => false, + :has_job_income => true, + :has_self_employment_income => false, + :has_unemployment_income => false, + :has_other_income => false, + :has_deductions => false, + :has_enrolled_health_coverage => false, + :has_eligible_health_coverage => false, + :medicaid_and_chip => medicaid_and_chip, + :addresses => addresses, + :incomes => incomes, + :is_medicare_eligible => false, + :has_insurance => false, + :has_state_health_benefit => false, + :had_prior_insurance => false, + :age_of_applicant => 22, + :is_self_attested_long_term_care => false, + :hours_worked_per_week => 0, + :is_temporarily_out_of_state => false, + :is_claimed_as_dependent_by_non_applicant => false, + :benchmark_premium => benchmark_premium, + :is_homeless => false, + :mitc_income => mitc_income, + :mitc_relationships => [], + :local_mec_evidence => local_mec_evidence + } + end # rubocop:enable Metrics/MethodLength def local_mec_evidence @@ -243,7 +248,34 @@ def tax_household_member_determination(f_name, l_name, hbx_id) :magi_medicaid_monthly_household_income => 6_000, :is_non_magi_medicaid_eligible => false, :is_without_assistance => false, - :category_determinations => category_determinations + :category_determinations => category_determinations, + :member_determinations => [eligible_member_determination] + }, + :applicant_reference => { + :first_name => f_name, + :last_name => l_name, + :dob => member_dob, + :person_hbx_id => hbx_id + } + } + end + + def ineligible_tax_household_member_determination(f_name, l_name, hbx_id) + { + :product_eligibility_determination => { + :is_ia_eligible => false, + :is_medicaid_chip_eligible => false, + :is_totally_ineligible => true, + :is_magi_medicaid => false, + :is_uqhp_eligible => nil, + :is_csr_eligible => false, + :is_eligible_for_non_magi_reasons => false, + :csr => "94", + :magi_medicaid_monthly_household_income => 6_000, + :is_non_magi_medicaid_eligible => false, + :is_without_assistance => false, + :category_determinations => category_determinations, + :member_determinations => [ineligible_member_determination] }, :applicant_reference => { :first_name => f_name, @@ -254,10 +286,32 @@ def tax_household_member_determination(f_name, l_name, hbx_id) } end + def eligible_member_determination + { + :kind => 'Insurance Assistance Determination', + :criteria_met => true, + :determination_reasons => [], + eligibility_overrides: [] + } + end + + def ineligible_member_determination + { + :kind => 'Insurance Assistance Determination', + :criteria_met => true, + :determination_reasons => [ + 'total_ineligibility_no_state_residency', + 'total_ineligibility_no_lawful_presence' + ], + eligibility_overrides: [] + } + end + def tax_household_members_faa [ tax_household_member_determination('Gerald', 'Rivers', '1009501'), - tax_household_member_determination('Alicia', 'Rivers', '1009502') + tax_household_member_determination('Alicia', 'Rivers', '1009502'), + ineligible_tax_household_member_determination('Brock', 'Rivers', '1009503') ] end