forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor GitHub Actions workflow for improved testing and caching #10
Open
Gkrumbach07
wants to merge
13
commits into
main
Choose a base branch
from
faster-cypress
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+99
−154
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
854bf36
Refactor GitHub Actions workflow for improved testing and caching
Gkrumbach07 7c9071b
Enhance GitHub Actions workflow for Cypress testing
Gkrumbach07 b0ffee7
Enhance GitHub Actions workflow for Cypress testing
Gkrumbach07 8ecdaaa
Refine GitHub Actions workflow for Cypress testing
Gkrumbach07 8eb3db5
Remove obsolete Cypress test file for application functionality
Gkrumbach07 0b43f41
Refactor test group generation in GitHub Actions workflow
Gkrumbach07 c842ff3
Refactor test group generation in GitHub Actions workflow
Gkrumbach07 b7f4d83
Enhance GitHub Actions workflow for Cypress testing
Gkrumbach07 fe3b9f6
better
Gkrumbach07 a1a1418
bbb
Gkrumbach07 2abe220
Refactor test group generation in GitHub Actions workflow
Gkrumbach07 492c034
Update GitHub Actions workflow for linting and Cypress testing
Gkrumbach07 ccc9dd9
Refactor GitHub Actions workflow for Cypress testing
Gkrumbach07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
name: Test | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
Tests: | ||
Setup: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
|
@@ -12,51 +13,111 @@ jobs: | |
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Node.js modules cache, repository | ||
- name: Node.js modules cache | ||
uses: actions/cache@v4 | ||
id: repo-cache | ||
id: modules-cache | ||
with: | ||
path: ${{ github.workspace }}/node_modules | ||
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-repo-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ matrix.node-version }}-modules-repo | ||
- name: Node.js modules cache, backend | ||
path: | | ||
~/.cache/Cypress | ||
${{ github.workspace }}/node_modules | ||
${{ github.workspace }}/backend/node_modules | ||
${{ github.workspace }}/frontend/node_modules | ||
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }} | ||
- name: Install dependencies | ||
if: steps.modules-cache.outputs.cache-hit != 'true' | ||
run: npm install | ||
- name: Check for uncomitted changes | ||
run: git diff --exit-code | ||
|
||
Lint: | ||
needs: Setup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cache | ||
uses: actions/cache@v4 | ||
id: backend-cache | ||
with: | ||
path: ${{ github.workspace }}/backend/node_modules | ||
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-backend-${{ hashFiles('**/backend/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ matrix.node-version }}-modules-backend | ||
- name: Node.js modules cache, frontend | ||
path: | | ||
~/.cache/Cypress | ||
${{ github.workspace }}/node_modules | ||
${{ github.workspace }}/backend/node_modules | ||
${{ github.workspace }}/frontend/node_modules | ||
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }} | ||
- name: Run linting and formatting checks | ||
run: npm run test:fix | ||
|
||
Unit-Tests: | ||
needs: Setup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cache | ||
uses: actions/cache@v4 | ||
id: frontend-cache | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
${{ github.workspace }}/node_modules | ||
${{ github.workspace }}/backend/node_modules | ||
${{ github.workspace }}/frontend/node_modules | ||
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-frontend-${{ hashFiles('**/frontend/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ matrix.node-version }}-modules-frontend | ||
- name: Install Node.js packages | ||
if: ${{ steps.repo-cache.outputs.cache-hit != 'true' || steps.backend-cache.outputs.cache-hit != 'true' || steps.frontend-cache.outputs.cache-hit != 'true' }} | ||
run: npm install | ||
- name: Check for uncomitted changes | ||
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }} | ||
- name: Run unit tests | ||
run: npm run test:unit | ||
|
||
Get-Test-Groups: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
test-groups: ${{ steps.set-groups.outputs.test-groups }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: set-groups | ||
shell: bash | ||
run: | | ||
git diff --exit-code | ||
- name: Test backend & test frontend with code coverage | ||
if: ${{ success() }} | ||
run: npm run test:backend && npm run test:frontend:coverage | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: false | ||
name: frontend | ||
directory: ./frontend/coverage | ||
verbose: true | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ always() }} | ||
set -x # Enable debug mode to see each command | ||
|
||
echo "Checking directory structure..." | ||
ls -la frontend/src/__tests__/cypress/cypress/tests/ || echo "Base test directory not found" | ||
|
||
if [ -d "frontend/src/__tests__/cypress/cypress/tests/mocked" ]; then | ||
echo "Found mocked tests directory" | ||
|
||
# Get directories and create JSON array - force compact output with -c | ||
DIRS=$(cd frontend/src/__tests__/cypress/cypress/tests/mocked && \ | ||
find . -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | \ | ||
jq -R . | jq -c -s .) | ||
|
||
# Output in the correct format for GitHub Actions | ||
echo "test-groups=$DIRS" >> "$GITHUB_OUTPUT" | ||
|
||
echo "Generated test groups:" | ||
cat "$GITHUB_OUTPUT" | ||
else | ||
echo "No mocked tests directory found, using default" | ||
echo "test-groups=[\"default\"]" >> "$GITHUB_OUTPUT" | ||
fi | ||
|
||
Cypress-Tests: | ||
needs: [Setup, Get-Test-Groups] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also require the Unit-Tests to pass successfully in order to execute the Mocks? If any of the Unit tests there is a possibility that the mocks would also fail. |
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test-group: ${{ fromJson(needs.Get-Test-Groups.outputs.test-groups) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cache | ||
uses: actions/cache@v4 | ||
with: | ||
name: cypress-results | ||
path: ./frontend/src/__tests__/cypress/results/ | ||
path: | | ||
~/.cache/Cypress | ||
${{ github.workspace }}/node_modules | ||
${{ github.workspace }}/backend/node_modules | ||
${{ github.workspace }}/frontend/node_modules | ||
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }} | ||
- name: Run Cypress tests | ||
run: | | ||
if [ "${{ matrix.test-group }}" == "default" ]; then | ||
npm run test:cypress-ci | ||
else | ||
npm run test:cypress-ci -- --spec "src/__tests__/cypress/cypress/tests/mocked/${{ matrix.test-group }}/**/*" | ||
fi | ||
working-directory: ./frontend |
116 changes: 0 additions & 116 deletions
116
frontend/src/__tests__/cypress/cypress/tests/mocked/application.cy.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to Cypress-Mock-Tests? In the future we may also want to include e2e Cypress tests in this workflow.