Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 58 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,71 @@
name: "build"
name: "Build CI/CD Pipeline"

on:
pull_request:
schedule:
- cron: "0 0 * * *" # Run everyday
push:
branches: [main, develop]
Copy link
Member

Choose a reason for hiding this comment

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

This repo has no main or develop branch, so this change disables all push testing.

paths-ignore:
- "*.md"
- "docs/**"

pull_request:
branches: [main]
Copy link
Member

Choose a reason for hiding this comment

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

This repo has no main branch, so this change disables all pull request testing.

types: [opened, synchronize, reopened]
Copy link
Member

Choose a reason for hiding this comment

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

Why these?

paths-ignore:
- "*.md"
- "docs/**"
Copy link
Member

Choose a reason for hiding this comment

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

Why ignore these? docs contains Python code.

schedule:
- cron: "0 0 * * *"

Copy link
Member

Choose a reason for hiding this comment

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

Why this blank line?

workflow_dispatch:

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v6
- name: Checkout Repository
Copy link
Member

@cclauss cclauss Aug 23, 2025

Choose a reason for hiding this comment

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

This step only has a name but no run or uses so this GHA is invalid https://github.com/TheAlgorithms/Python/actions/runs/17159313101

Copy link
Author

Choose a reason for hiding this comment

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

Fixed it

Copy link
Member

Choose a reason for hiding this comment

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

uses: actions/checkout@v5

- name: Set up uv
Copy link
Member

Choose a reason for hiding this comment

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

astral-sh/setup-uv@v3 tells the reader more than Set up uv does.

uses: astral-sh/setup-uv@v3
Copy link
Member

Choose a reason for hiding this comment

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

Why revert:

This undoes the work of many smart contributors without providing any reason for doing so.

with:
enable-cache: true
cache-dependency-glob: uv.lock
- uses: actions/setup-python@v5
cache-dependency-glob: |
**/uv.lock
**/pyproject.toml
Copy link
Member

@cclauss cclauss Aug 23, 2025

Choose a reason for hiding this comment

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

Where in the uv or setup-uv documentation is this change recommended? The contents of uv.lock are a superset of the dependency information in pyproject.toml. There are tons of changes possible in pyproject.toml that have nothing to do with dependencies.

- name: Set up Python
uses: actions/setup-python@v5
Copy link
Member

Choose a reason for hiding this comment

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

The hyphen on line 37 makes this entire file invalid.

actions/setup-python@v5 tells the reader more than Set up Python.

with:
python-version: 3.x
python-version: "3.11"
Copy link
Member

Choose a reason for hiding this comment

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

allow-prereleases: true
- run: uv sync --group=test
- name: Install dependencies
Copy link
Member

Choose a reason for hiding this comment

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

uv sync --group=test tells the reader more than Install dependencies.

run: |
uv sync --all-extras
uv pip list
Comment on lines +43 to +44
Copy link
Member

Choose a reason for hiding this comment

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

Not helpful. This has the potential to slow down the build and generate longer logs, which will go unread.

- name: Lint code
run: uv run ruff check . --output-format=github
Copy link
Member

@cclauss cclauss Aug 23, 2025

Choose a reason for hiding this comment

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

Why run ruff again? It is already run in the pre-commit and dedicated ruff jobs.

- name: Run tests
# TODO: #8818 Re-enable quantum tests
run: uv run pytest
--ignore=computer_vision/cnn_classification.py
--ignore=docs/conf.py
--ignore=dynamic_programming/k_means_clustering_tensorflow.py
--ignore=machine_learning/lstm/lstm_prediction.py
--ignore=neural_network/input_data.py
--ignore=project_euler/
--ignore=quantum/q_fourier_transform.py
--ignore=scripts/validate_solutions.py
--ignore=web_programming/current_stock_price.py
--ignore=web_programming/fetch_anime_and_play.py
--cov-report=term-missing:skip-covered
--cov=. .
- if: ${{ success() }}
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
Comment on lines -37 to -38
Copy link
Member

Choose a reason for hiding this comment

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

The if and run commands need to be placed in the same job step, not in two separate job steps.

run: |
uv run pytest \
--ignore=computer_vision/cnn_classification.py \
--ignore=docs/conf.py \
--ignore=dynamic_programming/k_means_clustering_tensorflow.py \
--ignore=machine_learning/lstm/lstm_prediction.py \
--ignore=neural_network/input_data.py \
--ignore=project_euler/ \
--ignore=quantum/q_fourier_transform.py \
--ignore=scripts/validate_solutions.py \
--ignore=web_programming/current_stock_price.py \
--ignore=web_programming/fetch_anime_and_play.py \
--cov-report=term-missing:skip-covered \
--cov=. .

- name: Build package (if needed)
run: uv build
if: ${{ success() }}

- name: Generate Directory Markdown
run: python scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
if: ${{ success() }}