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

chore: test cache #16390

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

chore: test cache #16390

wants to merge 4 commits into from

Conversation

lodmfjord
Copy link
Member

@lodmfjord lodmfjord commented Oct 14, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced a new GitHub Actions workflow named "Cache Hack" for improved caching management.
    • Enhanced the pull request workflow with new steps to set caching and runtime environment variables across multiple jobs.
  • Bug Fixes

    • Removed the previous caching action to streamline the caching process.
  • Chores

    • Minor formatting adjustments made for improved readability of workflow files.

@lodmfjord lodmfjord requested a review from a team as a code owner October 14, 2024 16:18
Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Caution

Review failed

The head commit changed during the review from 9c662b6 to 02c9098.

Walkthrough

A new GitHub Actions composite action named "Cache Hack" has been introduced in .github/actions/cache-hack/action.yml, replacing the previous caching action. This new action is designed to manage caching behavior by setting specific environment variables. Additionally, multiple jobs in the .github/workflows/pullrequest.yml file have been updated to include steps that utilize the actions/github-script@v7 action for exporting these environment variables, enhancing caching and runtime configurations.

Changes

File Change Summary
.github/actions/cache-hack/action.yml - Added new composite action "Cache Hack" with environment variable setup.
- Removed previous caching action and its parameters.
.github/workflows/pullrequest.yml - Updated multiple jobs to include steps for exporting caching-related environment variables.
- Minor formatting adjustments for readability.

Possibly related PRs

  • ci: cache refactor #15103: The changes in this PR involve refactoring caching mechanisms in the CI process, which relates to the introduction of a new caching action in the main PR.
  • fix: cache #15475: This PR addresses issues related to caching, specifically updating cache keys, which connects to the modifications made in the main PR regarding caching behavior.
  • fix: bug #15499: This PR includes updates to caching-related environment variables and paths, which aligns with the caching changes introduced in the main PR.
  • chore(scripts): Stricter shell script checking #16242: Although primarily focused on shell script checking, this PR modifies the .github/workflows/pullrequest.yml, which is also affected by the caching changes in the main PR.
  • fix: pre-release #16308: This PR modifies the workflow logic in .github/workflows/push.yml, which is relevant to the overall workflow changes that include caching behavior adjustments in the main PR.

Suggested labels

automerge, deploy-feature, test everything

Suggested reviewers

  • AndesKrrrrrrrrrrr

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@robertaandersen robertaandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
.github/actions/cache-hack/action.yml (2)

1-2: Consider improving the action name and description.

The current name "Cache Hack" and description "Hack cache" are not very professional or informative. Consider using a more descriptive name and providing a clearer explanation of the action's purpose.

For example:

name: 'Custom Cache Configuration'
description: 'Sets up custom caching environment variables for GitHub Actions'

15-15: Fix formatting issues.

There are two minor formatting issues in the file:

  1. Trailing spaces at the end of line 15.
  2. Missing newline character at the end of the file.

Please remove the trailing spaces and add a newline at the end of the file to adhere to YAML best practices and improve consistency.

🧰 Tools
🪛 yamllint

[error] 15-15: no new line character at the end of file

(new-line-at-end-of-file)


[error] 15-15: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 83b076f and 6875592.

📒 Files selected for processing (3)
  • .github/actions/cache-hack/action.yml (1 hunks)
  • .github/actions/cache/action.yml (0 hunks)
  • .github/workflows/pullrequest.yml (8 hunks)
💤 Files with no reviewable changes (1)
  • .github/actions/cache/action.yml
🧰 Additional context used
🪛 yamllint
.github/actions/cache-hack/action.yml

[error] 15-15: no new line character at the end of file

(new-line-at-end-of-file)


[error] 15-15: trailing spaces

(trailing-spaces)

🔇 Additional comments (3)
.github/actions/cache-hack/action.yml (2)

3-7: Action configuration looks good.

The composite action setup and the initial step definition are correct and well-structured.


8-14: 🛠️ Refactor suggestion

Consider making the cache URL configurable and review security implications.

  1. The ACTIONS_CACHE_URL is hardcoded to https://cache.dev01.devland.is/. Consider making this URL configurable through an input parameter to improve the action's flexibility and reusability across different environments.

  2. Be cautious when exporting ACTIONS_RUNTIME_TOKEN. Ensure that this token has the minimum required permissions and that it's not exposed in logs or outputs.

Example of making the URL configurable:

inputs:
  cache_url:
    description: 'URL for the custom cache server'
    required: true
    default: 'https://cache.dev01.devland.is/'

steps:
  - name: Adding required env vars
    uses: actions/github-script@v7
    env:
      github-token: ${{ inputs.GITHUB_TOKEN }}
    with:
      script: |
        core.exportVariable('ACTIONS_CACHE_URL', '${{ inputs.cache_url }}')
        core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
        core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])

To ensure the ACTIONS_RUNTIME_TOKEN is not being misused, you can run the following script:

.github/workflows/pullrequest.yml (1)

Line range hint 1-480: Overall workflow changes improve consistency but introduce redundancy

The changes made to this workflow file consistently add environment variable configuration for caching and runtime across all jobs. This improves the overall consistency of the workflow and ensures that all jobs operate with the same caching and runtime settings.

However, the repetitive nature of these changes introduces potential maintenance challenges. If these configurations need to be updated in the future, changes would need to be made in multiple places, increasing the risk of errors or inconsistencies.

To address this, consider implementing a centralized solution for setting these environment variables, such as a reusable workflow or composite action, as suggested in previous comments. This would significantly improve the maintainability of the workflow while preserving the benefits of the current changes.

Aside from this main change, no other significant issues or changes were observed in the workflow file.

Comment on lines +43 to +48
- uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', 'https://cache.dev01.devland.is/')
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider parameterizing the ACTIONS_CACHE_URL

The addition of this step to set environment variables for caching and runtime configuration is a good practice for managing these settings across the workflow. However, the ACTIONS_CACHE_URL is hardcoded, which might make it difficult to change in the future if needed.

Consider parameterizing this URL, perhaps by using a repository secret or a configuration file, to make it more flexible and easier to manage across environments.

- uses: actions/github-script@v7
  with:
    script: |
      core.exportVariable('ACTIONS_CACHE_URL', '${{ secrets.ACTIONS_CACHE_URL }}')
      core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
      core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])

Comment on lines +195 to +200
- uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', 'https://cache.dev01.devland.is/')
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using a reusable workflow for setting environment variables

The addition of this step ensures consistent caching and runtime configuration across jobs, which is good. However, this exact code block is repeated in multiple jobs, which could lead to maintenance issues if changes are needed in the future.

Consider creating a reusable workflow or a composite action for setting these environment variables. This would centralize the configuration and make it easier to update across all jobs.

Example of a reusable workflow:

# .github/workflows/set-env-vars.yml
name: 'Set Environment Variables'
on:
  workflow_call:

jobs:
  set-env-vars:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            core.exportVariable('ACTIONS_CACHE_URL', 'https://cache.dev01.devland.is/')
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
            core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])

# Usage in your main workflow:
jobs:
  tests:
    uses: ./.github/workflows/set-env-vars.yml
    # ... rest of your job configuration

Comment on lines +247 to +252
- uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', 'https://cache.dev01.devland.is/')
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Implement a centralized solution for setting environment variables

The addition of the environment variable setting step across all jobs in the workflow ensures consistent caching and runtime configuration, which is a positive change. However, the repetition of this code block in every job (prepare, tests, e2e, linting-workspace, run-shellcheck, formatting, linting, and build) introduces potential maintenance issues.

To improve maintainability and reduce redundancy:

  1. Create a reusable workflow or composite action for setting these environment variables.
  2. Update all jobs to use this centralized solution.

This approach will make it easier to manage and update these configurations across the entire workflow in the future.

Example implementation using a composite action:

  1. Create a new file .github/actions/set-env-vars/action.yml:
name: 'Set Environment Variables'
description: 'Sets common environment variables for caching and runtime'
runs:
  using: "composite"
  steps:
    - uses: actions/github-script@v7
      with:
        script: |
          core.exportVariable('ACTIONS_CACHE_URL', 'https://cache.dev01.devland.is/')
          core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
          core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
  1. Update each job to use this action:
jobs:
  prepare:
    steps:
      - uses: ./.github/actions/set-env-vars
      # ... rest of the steps

  tests:
    steps:
      - uses: ./.github/actions/set-env-vars
      # ... rest of the steps

  # ... repeat for all other jobs

This change will centralize the environment variable setting logic and make it easier to maintain and update in the future.

Also applies to: 280-285, 309-314, 333-338, 388-393, 425-430

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.74%. Comparing base (83b076f) to head (02c9098).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16390      +/-   ##
==========================================
- Coverage   36.75%   36.74%   -0.01%     
==========================================
  Files        6807     6807              
  Lines      140972   140972              
  Branches    40145    40145              
==========================================
- Hits        51811    51807       -4     
- Misses      89161    89165       +4     
Flag Coverage Δ
air-discount-scheme-backend 54.06% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-air-discount-scheme 36.93% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-communications 39.91% <ø> (ø)
api-domains-criminal-record 48.00% <ø> (ø)
api-domains-driving-license 44.40% <ø> (ø)
api-domains-education 31.51% <ø> (ø)
api-domains-health-insurance 34.77% <ø> (ø)
api-domains-payment-schedule 41.16% <ø> (ø)
application-api-files 58.02% <ø> (ø)
application-core 71.85% <ø> (+0.32%) ⬆️
application-system-api 41.42% <ø> (ø)
application-template-api-modules 27.89% <ø> (+0.01%) ⬆️
application-templates-accident-notification 29.29% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.35% <ø> (ø)
application-templates-driving-license 18.29% <ø> (ø)
application-templates-estate 12.31% <ø> (ø)
application-templates-example-payment 25.14% <ø> (ø)
application-templates-financial-aid 14.27% <ø> (ø)
application-templates-general-petition 23.43% <ø> (ø)
application-templates-inheritance-report 6.43% <ø> (ø)
application-templates-marriage-conditions 15.09% <ø> (ø)
application-templates-mortgage-certificate 43.78% <ø> (ø)
application-templates-parental-leave 29.97% <ø> (ø)
application-types 6.69% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.35% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.67% <ø> (ø)
clients-driving-license-book 43.80% <ø> (ø)
clients-financial-statements-inao 49.32% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-regulations 42.80% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.44% <ø> (ø)
cms 0.43% <ø> (ø)
cms-translations 39.04% <ø> (ø)
dokobit-signing 63.38% <ø> (ø)
download-service 44.21% <ø> (ø)
email-service 61.13% <ø> (ø)
feature-flags 91.11% <ø> (ø)
file-storage 53.71% <ø> (ø)
financial-aid-backend 56.40% <ø> (ø)
judicial-system-api 18.39% <ø> (ø)
judicial-system-audit-trail 69.35% <ø> (ø)
judicial-system-backend 55.19% <ø> (ø)
judicial-system-message 67.24% <ø> (ø)
judicial-system-message-handler 48.35% <ø> (ø)
judicial-system-scheduler 69.54% <ø> (ø)
license-api 42.67% <ø> (-0.08%) ⬇️
nest-config 78.44% <ø> (ø)
nest-feature-flags 51.52% <ø> (ø)
nova-sms 62.74% <ø> (ø)
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 16.15% <ø> (ø)
services-auth-admin-api 51.84% <ø> (ø)
services-auth-delegation-api 57.32% <ø> (-0.07%) ⬇️
services-auth-ids-api 51.41% <ø> (-0.03%) ⬇️
services-auth-personal-representative 45.16% <ø> (ø)
services-auth-personal-representative-public 41.28% <ø> (+0.01%) ⬆️
services-auth-public-api 48.91% <ø> (-0.01%) ⬇️
services-endorsements-api 54.19% <ø> (ø)
services-sessions 65.33% <ø> (-0.05%) ⬇️
services-university-gateway 48.28% <ø> (-0.03%) ⬇️
services-user-notification 47.02% <ø> (ø)
services-user-profile 62.18% <ø> (ø)
web 1.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 83b076f...02c9098. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 14, 2024

Datadog Report

All test runs 7ffc4ed 🔗

70 Total Test Services: 0 Failed, 67 Passed
🔻 Test Sessions change in coverage: 2 decreased, 1 increased (+0.01%), 197 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 81 0 31.49s N/A Link
air-discount-scheme-web 0 0 0 2 0 9.19s N/A Link
api 0 0 0 4 0 2.56s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 17.4s N/A Link
api-domains-assets 0 0 0 3 0 11.08s N/A Link
api-domains-auth-admin 0 0 0 18 0 13.07s N/A Link
api-domains-communications 0 0 0 5 0 30.97s N/A Link
api-domains-criminal-record 0 0 0 5 0 9.38s N/A Link
api-domains-driving-license 0 0 0 23 0 29.67s N/A Link
api-domains-education 0 0 0 8 0 20.25s N/A Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • services-auth-delegation-api - jest 51.24% (-0.18%) - Details
  • license-api - jest 33.92% (-0.02%) - Details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants