-
Notifications
You must be signed in to change notification settings - Fork 7
Update packages to address GHSA-mh29-5h37-fv8m & add Jest, ESlint, Playwright and Ruff support #43
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d0ba524
basic jest setup
AlexJSully ca6901f
setup basic playwright e2e tests
AlexJSully e2fc68b
set-up eslint
AlexJSully ceeceb5
python linting and formatting
AlexJSully 85c313a
update Actions
AlexJSully 8092b78
maybe
AlexJSully c705584
eh
AlexJSully 47f9fb6
forgot to delete tests
AlexJSully 35c524e
eeh again
AlexJSully 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Code Quality Assurance - Python | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "cgi-bin/**/*.cgi" | ||
| - "requirements*.txt" | ||
| - ".github/workflows/code-qa-python.yaml" | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - "cgi-bin/**/*.cgi" | ||
| - "requirements*.txt" | ||
| - ".github/workflows/code-qa-python.yaml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| python-version: [3.13] | ||
|
|
||
| steps: | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| version: "latest" | ||
|
|
||
| - name: Cache Python packages | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cache/uv | ||
| ~/.cache/pip | ||
| key: ${{ runner.os }}-python-${{ hashFiles('**/requirements*.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-python- | ||
|
|
||
| - name: Create virtual environment | ||
| run: uv venv | ||
|
|
||
| - name: Install dependencies | ||
| run: make py-install | ||
|
|
||
| - name: Format check - Ruff | ||
| run: uv run ruff format cgi-bin/*.cgi | ||
|
|
||
| - name: Lint check - Ruff | ||
| run: uv run ruff check --fix cgi-bin/*.cgi | ||
|
|
||
| - name: Run Python tests | ||
| run: uv run pytest |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Validate all | ||
| .PHONY: validate-all | ||
| validate-all: py-validate | ||
| # Validate JavaScript/TypeScript | ||
| # If node_modules is missing, run 'npm install' first | ||
| @if [ ! -d node_modules ]; then npm ci; fi | ||
| npm run validate | ||
| # Validate R installation | ||
| Rscript -e 'renv::restore()' | ||
|
|
||
| # === Python Commands for eFP-Seq_Browser === | ||
| .PHONY: py-install py-format py-lint py-test py-clean py-validate | ||
|
|
||
| PY_FILES = cgi-bin/*.cgi | ||
|
|
||
| py-install: | ||
| uv pip install -r requirements-dev.txt | ||
|
|
||
| py-format: | ||
| uv run ruff format $(PY_FILES) | ||
|
|
||
| py-lint: | ||
| uv run ruff check --fix $(PY_FILES) | ||
|
|
||
| py-validate: py-install py-format py-lint |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /** | ||
| * @jest-environment jsdom | ||
| */ | ||
|
|
||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
|
|
||
| describe("update (XMLgenerator.js)", () => { | ||
| let update; | ||
| let $; | ||
|
|
||
| beforeAll(() => { | ||
| // Minimal jQuery mock | ||
| $ = () => ({ | ||
| find: (selector) => ({ | ||
| val: () => { | ||
| const map = { | ||
| ".channelcontrols": "ctrl1, ctrl2", | ||
| ".channelgroupwidtho": "rep1, rep2", | ||
| ".channeldescription": "desc", | ||
| ".channelrecordnumber": "42", | ||
| ".channelhexcolor": "#ff0000", | ||
| ".channelbamType": "Google Drive", | ||
| ".channelbamlink": "https://drive.google.com/file/d/abc", | ||
| ".channeltotalreadsmapped": "12345", | ||
| ".channelreadmapmethod": "STAR", | ||
| ".channelpublicationlink": "https://pub.com/xyz", | ||
| ".channeltissue": "Leaf", | ||
| ".channelsvgname": "ath-leaf.svg", | ||
| ".channeltitle": "Test Title", | ||
| ".channelsralink": "SRR000001", | ||
| ".channelspecies": "Arabidopsis", | ||
| ".channelforeground": "#000000", | ||
| ".channelfilename": "file1.bam", | ||
| }; | ||
| return map[selector] || "dummy"; | ||
| }, | ||
| }), | ||
| }); | ||
|
|
||
| // Robust document.getElementById mock for all ids | ||
| const getElementByIdMock = (id) => { | ||
| const values = { | ||
| reqxml: { value: "TestXML" }, | ||
| reqauthor: { value: "Author" }, | ||
| contectinfo: { value: "contact@email.com" }, | ||
| }; | ||
| return values[id] || { value: "dummy" }; | ||
| }; | ||
| if (global.document) { | ||
| global.document.getElementById = getElementByIdMock; | ||
| } else { | ||
| global.document = { getElementById: getElementByIdMock }; | ||
| } | ||
| global.$ = $; | ||
|
|
||
| // Required top-level variables for update() | ||
| global.topXML = [ | ||
| '\t\t<file info="<?channeldescription?>" record_number="<?channelrecordnumber?>" foreground="<?channelforeground?>" hex_colour="<?channelhexcolor?>" bam_type="<?channelbamType?>" name="<?channelbamlink?>" filename="<?channelfilename?>" total_reads_mapped="<?channeltotalreadsmapped?>" read_map_method="<?channelreadmapmethod?>" publication_link="<?channelpublicationlink?>" svg_subunit="<?channeltissue?>" svgname="<?channelsvgname?>" description="<?channeltitle?>" url="<?channelsralink?>" species="<?channelspecies?>" title="<?channeligbtitle?>">', | ||
| "\t\t\t<controls>\n", | ||
| ].join("\r\n"); | ||
| global.controlsXML = ""; | ||
| global.replicatesXML = ["\t\t\t</controls>", "\t\t\t<groupwith>\n"].join("\r\n"); | ||
| global.endingXML = ["\t\t\t</groupwith>", "\t\t</file>", "\n"].join("\r\n"); | ||
| global.existingXML = ""; | ||
| global.all_controls = ""; | ||
| global.all_replicates = ""; | ||
|
|
||
| // Load the update function from XMLgenerator.js | ||
| const code = fs.readFileSync(path.join(__dirname, "../Submission_page/XMLgenerator.js"), "utf8"); | ||
| const fnMatch = code.match(/function update\s*\(([^)]*)\)\s*{([\s\S]*?)^}/m); | ||
| if (!fnMatch) throw new Error("update function not found in XMLgenerator.js"); | ||
| const args = fnMatch[1]; | ||
| const body = fnMatch[2]; | ||
|
|
||
| update = new Function(args, body); | ||
| }); | ||
|
|
||
| it("generates correct XML for given form values", () => { | ||
| const v = {}; // dummy, not used in our $ mock | ||
| const result = update("", v); | ||
| // Check for key XML elements and values | ||
| expect(result).toContain('info="desc"'); | ||
| expect(result).toContain('record_number="42"'); | ||
| expect(result).toContain('hex_colour="#ff0000"'); | ||
| expect(result).toContain('bam_type="Google Drive"'); | ||
| expect(result).toContain('name="https://drive.google.com/file/d/abc"'); | ||
| expect(result).toContain('filename="file1.bam"'); | ||
| expect(result).toContain("<bam_exp>ctrl1</bam_exp>"); | ||
| expect(result).toContain("<bam_exp>ctrl2</bam_exp>"); | ||
| expect(result).toContain("<bam_exp>rep1</bam_exp>"); | ||
| expect(result).toContain("<bam_exp>rep2</bam_exp>"); | ||
| }); | ||
| }); |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.