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

[7650] Figure out flaky #4719

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
76 changes: 76 additions & 0 deletions .github/actions/coverage-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Coverage tests
description: runs code coverage tests


inputs:
docker-image:
required: true
type: string
image-tag:
required: true
type: string
use-next-academic-year:
required: true
type: boolean
azure-credentials:
required: true
type: string
slack-webhook:
required: true
type: string
codecov-token:
required: true
type: string

runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Bring docker image up
uses: ./.github/actions/bring-docker-image-up/
with:
azure-credentials: ${{ inputs.azure-credentials }}
docker-image: ${{ inputs.docker-image}}
image-tag: ${{ inputs.image-tag }}

- name: Setup tests dependencies on images
shell: bash
run: |
docker compose exec -T web /bin/sh -c 'bundle config --local disable_exec_load true'
docker compose exec -T web /bin/sh -c 'bundle exec rake parallel:setup'
docker compose exec -T web /bin/sh -c "yarn add [email protected]"
docker compose exec -T web /bin/sh -c "RAILS_ENV=test bundle exec rails assets:precompile"
docker compose exec -T web /bin/sh -c 'apk add chromium chromium-chromedriver'

- name: "${{ inputs.use-next-academic-year && 'Next academic year' || 'Current academic year' }} coverage tests"
shell: bash
run: |
docker compose exec -T web /bin/sh -c 'COVERAGE=true bundle exec --verbose rspec --pattern "spec/**/*_spec.rb" --exclude-pattern "spec/smoke/*_spec.rb"'
env:
USE_NEXT_ACADEMIC_YEAR: ${{ inputs.use-next-academic-year }}

- name: Flaky flush
shell: bash
run: |
docker compose exec -T web /bin/sh -c 'for i in {1..100} do bundle exec --verbose rspec ./spec/features/end_to_end/provider_led_undergrad_journey_spec.rb:10 end'
env:
USE_NEXT_ACADEMIC_YEAR: ${{ inputs.use-next-academic-year }}

# - name: Check for Failure
# uses: ./.github/actions/send-slack-notification/
# if: ${{ failure() && github.ref == 'refs/heads/main' }}
# with:
# slack-title: "${{ inputs.use-next-academic-year && 'Next academic year' || 'Current academic year' }} tests"
# slack-message: "':alert: ${{ inputs.use-next-academic-year && 'Next academic year' || 'Current academic year'}} coverage test failure on commit ${{env.IMAGE_TAG}} :sadpanda:"
# slack-webhook: ${{ inputs.slack-webhook }}

# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# files: ./coverage/backend/coverage.json
# token: ${{ inputs.codecov-token }}
# flags: unittests
# name: codecov-umbrella
# fail_ci_if_error: false
25 changes: 18 additions & 7 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
workflow_dispatch:
schedule:
- cron: "0 23 * * *"
pull_request:
types: [opened, reopened, synchronize, labeled]

permissions:
contents: write
Expand Down Expand Up @@ -35,12 +37,21 @@ jobs:
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS_REVIEW }}

test:
coverage_tests:
name: Coverage tests
needs: [build]
uses: ./.github/workflows/coverage-tests.yml
secrets: inherit
with:
docker-image: ${{needs.build.outputs.docker-image}}
image-tag: ${{ needs.build.outputs.image-tag }}
use-next-academic-year: false

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Coverage Tests
uses: ./.github/actions/coverage-tests/
with:
docker-image: ${{needs.build.outputs.docker-image}}
image-tag: ${{ needs.build.outputs.image-tag }}
use-next-academic-year: false
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS_REVIEW }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
64 changes: 0 additions & 64 deletions .github/workflows/coverage-tests.yml

This file was deleted.

27 changes: 14 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ jobs:
]
include:
- test-type: unit_models
include-pattern: spec/models/*_spec.rb
include-pattern: spec/models/**/*_spec.rb
- test-type: unit_services
include-pattern: spec/services/*_spec.rb
include-pattern: spec/services/**/*_spec.rb
- test-type: unit_forms
include-pattern: spec/forms/*_spec.rb
include-pattern: spec/forms/**/*_spec.rb
- test-type: unit_components
include-pattern: spec/components/*_spec.rb
include-pattern: spec/components/**/*_spec.rb
- test-type: unit_other
include-pattern: spec/*_spec.rb
exclude-pattern: spec/(features|smoke|models|services|forms|components)/*_spec.rb
include-pattern: spec/**/*_spec.rb
exclude-pattern: spec/{features,smoke,models,services,forms,components}/**/*_spec.rb
- test-type: integration_end_to_end
include-pattern: spec/features/end_to_end/*_spec.rb
include-pattern: spec/features/end_to_end/**/*_spec.rb
- test-type: integration_form_sections
include-pattern: spec/features/form_sections/*_spec.rb
include-pattern: spec/features/form_sections/**/*_spec.rb
- test-type: integration_system_admin
include-pattern: spec/features/system_admin/*_spec.rb
include-pattern: spec/features/system_admin/**/*_spec.rb
- test-type: integration_trainee_actions
include-pattern: spec/features/trainee_actions/*_spec.rb
include-pattern: spec/features/trainee_actions/**/*_spec.rb
- test-type: integration_other
include-pattern: spec/features/*_spec.rb
exclude-pattern: spec/features/(end_to_end|form_sections|system_admin|trainee_actions)/*_spec.rb
include-pattern: spec/features/**/*_spec.rb
exclude-pattern: spec/features/{end_to_end,form_sections,system_admin,trainee_actions}/**/*_spec.rb

steps:
- name: Checkout
Expand All @@ -79,8 +79,9 @@ jobs:

- name: "${{ inputs.use-next-academic-year && 'Next academic year' || 'Current academic year' }} ${{ matrix.test-type }} tests"
uses: Wandalen/[email protected]
timeout-minutes: 15
with:
attempt_limit: 5
attempt_limit: 3
command: |
docker compose exec -T web /bin/sh -c 'USE_NEXT_ACADEMIC_YEAR=${{env.USE_NEXT_ACADEMIC_YEAR}} bundle exec --verbose rspec --pattern "${{ env.INCLUDE_PATTERN }}" --exclude-pattern "${{ env.EXCLUDE_PATTERN }}"'
env:
Expand Down
5 changes: 3 additions & 2 deletions app/services/lead_partner_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ def all_lead_partners
if query
lead_partners = lead_partners
.includes(:provider, :school)
.joins(:school)
.where("lead_partners.name ilike ?", "%#{query}%")
.or(School.where("postcode ilike ?", "%#{query}%"))
.or(LeadPartner.kept.where("lead_partners.urn ilike ?", "%#{query}%"))
.or(LeadPartner.kept.where("lead_partners.ukprn ilike ?", "%#{query}%"))
.or(LeadPartner.kept.where(id:
LeadPartner.kept.joins(:school).where(school: School.where("postcode ilike ?", "%#{query}%")).select(:id)))

end
lead_partners.reorder(:name)
end
Expand Down
2 changes: 0 additions & 2 deletions spec/fixtures/files/hpitt_degree_import.csv

This file was deleted.

40 changes: 34 additions & 6 deletions spec/services/degrees/create_from_csv_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,40 @@ module Degrees
let(:trainee) { create(:trainee) }
let(:degree) { trainee.degrees.first }
let(:csv_row) do
CSV.read(
file_fixture("hpitt_degree_import.csv").to_path,
headers: true,
encoding: "ISO-8859-1",
header_converters: ->(f) { f&.strip },
).first
{ "Provider trainee ID" => "A2",
"Region" => "London",
"First names" => "Adam",
"Middle names" => nil,
"Last names" => "Test",
"Date of birth" => "21/09/1997",
"Sex" => "Male",
"Nationality" => "british",
"UK address: Line 1" => "99 Lovely Road",
"UK address: Line 2" => nil,
"UK address: town or city" => "Oxford",
"UK Address 1: Postcode" => "OX41RG",
"Outside UK address" => nil,
"Email" => "[email protected]",
"Ethnicity" => "White - English, Scottish, Welsh, Northern Irish or British",
"Disabilities" => "Not provided",
"Course level" => nil,
"Course education phase" => "Secondary",
"Course age range" => "11 to 16",
"Course ITT subject 1" => "Mathematics",
"Course ITT subject 2" => nil,
"Course ITT Subject 3" => nil,
"Course study mode" => "full-time",
"Course ITT start date" => "2022-09-09",
"Course Expected End Date" => "31/07/2023",
"Trainee start date" => "09/09/2022",
"Employing school URN" => "131609",
"Degree: country" => "United Kingdom",
"Degree: subjects" => "Philosophy, Politics, Economics",
"Degree: UK degree types" => "Bachelor of Arts",
"Degree: UK awarding institution" => "University of Oxford",
"Degree: UK grade" => "Upper second-class honours (2:1)",
"Degree: Non-UK degree types" => nil,
"Degree: graduation year" => "2018" }
end

describe "#call" do
Expand Down
Loading