From 56ab63db01e3e26405286f2aa8842f274e389d48 Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 11:22:31 -0800 Subject: [PATCH 01/17] Fix caching issues in github workflow --- .github/workflows/docker-auto-test.yaml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 1c7976d15..30c21c1dc 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -32,18 +32,10 @@ jobs: uses: actions/cache@v3 with: path: ~/.cache/pypoetry - key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + key: ${{ runner.os }}-poetry-${{ hashFiles('backend/poetry.lock') }} restore-keys: | ${{ runner.os }}-poetry- - - name: Cache Docker images - uses: actions/cache@v3 - with: - path: /var/lib/docker - key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }} - restore-keys: | - ${{ runner.os }}-docker- - - name: Install Poetry run: pip install poetry==1.6.1 @@ -110,7 +102,6 @@ jobs: report_individual_runs: "true" deduplicate_classes_by_file_name: "true" - frontend-tests: runs-on: ubuntu-latest steps: @@ -127,7 +118,7 @@ jobs: uses: actions/cache@v3 with: path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- @@ -162,4 +153,4 @@ jobs: check_name: "Frontend Test Results" fail_on: "errors" report_individual_runs: "true" - deduplicate_classes_by_file_name: "true" + deduplicate_classes_by_file_name: "true" \ No newline at end of file From 71c2d5b628911eb3c4cb3c9a0a5c932b805d3320 Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 11:33:57 -0800 Subject: [PATCH 02/17] . --- backend/test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 backend/test.txt diff --git a/backend/test.txt b/backend/test.txt new file mode 100644 index 000000000..6a1013938 --- /dev/null +++ b/backend/test.txt @@ -0,0 +1 @@ +testing workflow, remove after testing. \ No newline at end of file From 971335bd93911d90e1364518c2af00a12d91c18d Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 11:48:12 -0800 Subject: [PATCH 03/17] optimize --- .github/workflows/docker-auto-test.yaml | 9 +++++ backend/Dockerfile | 44 +++++++++++-------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 30c21c1dc..5b11e92af 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -51,6 +51,15 @@ jobs: run: | sed -i 's/: true/: "true"/g; s/: false/: "false"/g' docker-compose.yml + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-docker-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-docker-${{ github.ref_name }} + ${{ runner.os }}-docker- + - name: Build and start services run: | docker-compose build diff --git a/backend/Dockerfile b/backend/Dockerfile index 2f863e90b..749325463 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,38 +1,31 @@ # Base stage for common setup FROM python:3.11-slim-bullseye as base -RUN apt-get update && apt-get install -y \ - gcc \ - && rm -rf /var/lib/apt/lists/* - -RUN pip install poetry==1.6.1 - -# Configuring poetry -RUN poetry config virtualenvs.create false - -# Copying requirements of a project -COPY pyproject.toml poetry.lock /app/ +# Install build dependencies and Poetry in one step to minimize layers +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + && pip install --no-cache-dir poetry==1.6.1 \ + && poetry config virtualenvs.create false \ + && apt-get purge -y gcc \ + && rm -rf /var/lib/apt/lists/* + +# Set work directory WORKDIR /app -# Installing requirements -RUN poetry install --only main +# Copy only dependency files first (to leverage caching) +COPY pyproject.toml poetry.lock /app/ -# Removing gcc -RUN apt-get purge -y \ - gcc \ - && rm -rf /var/lib/apt/lists/* +# Install only main dependencies +RUN poetry install --only main --no-root -# Copying the actual application, wait-for-it script, and prestart script +# Copy the rest of the application files COPY . /app/ -# Note: We mount the local directory using docker-compose so ensure these scripts also have execute permissions -# by running the following command on your host machine from the root of this project: -# chmod +x ./backend/wait-for-it.sh ./backend/lcfs/prestart.sh ./backend/lcfs/start.sh ./backend/lcfs/start-reload.sh - -# Make all startup scripts executable +# Make necessary scripts executable RUN chmod +x /app/wait-for-it.sh /app/lcfs/prestart.sh /app/lcfs/start.sh -CMD /bin/bash /app/lcfs/start.sh +# Default startup command +CMD ["/bin/bash", "/app/lcfs/start.sh"] # Production stage FROM base as prod @@ -43,5 +36,6 @@ ENV APP_ENVIRONMENT=prod FROM base as dev # Set the APP_ENVIRONMENT variable to 'development' ENV APP_ENVIRONMENT=dev + # Install additional dependencies for development -RUN poetry install +RUN poetry install --no-root From 92773a30a68fffe0cb2fd592191cefcc330b41a2 Mon Sep 17 00:00:00 2001 From: Hamed Valiollahi Bayeki Date: Thu, 12 Dec 2024 11:50:22 -0800 Subject: [PATCH 04/17] feat: add $ sign to fair market value per credit field in transfer input page --- .../Transfers/components/TransferDetails.jsx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/Transfers/components/TransferDetails.jsx b/frontend/src/views/Transfers/components/TransferDetails.jsx index c9e80f29a..22377b629 100644 --- a/frontend/src/views/Transfers/components/TransferDetails.jsx +++ b/frontend/src/views/Transfers/components/TransferDetails.jsx @@ -157,20 +157,21 @@ export const TransferDetails = () => { size="small" error={!!errors.pricePerUnit} helperText={errors.pricePerUnit?.message} - inputProps={{ - maxLength: 13, - step: '10', - style: { textAlign: 'right' }, - 'data-test': 'price-per-unit', - startadornment: ( - $ - ) - }} sx={{ - minWidth: '24rem', + minWidth: '25rem', marginInline: '0.2rem', bottom: '0.2rem' }} + InputProps={{ + startAdornment: ( + $ + ), + style: { textAlign: 'right' } + }} + inputProps={{ + maxLength: 13, + 'data-test': 'price-per-unit' + }} /> {t('transfer:totalValueText')} Date: Thu, 12 Dec 2024 11:54:50 -0800 Subject: [PATCH 05/17] update --- backend/test.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/test.txt b/backend/test.txt index 6a1013938..742cf3868 100644 --- a/backend/test.txt +++ b/backend/test.txt @@ -1 +1,2 @@ -testing workflow, remove after testing. \ No newline at end of file +testing workflow, remove after testing. +update to app files. \ No newline at end of file From 929e2fc33c30cd92ea26e65209e3eeddfe8024aa Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 11:59:59 -0800 Subject: [PATCH 06/17] Revert "optimize" This reverts commit 971335bd93911d90e1364518c2af00a12d91c18d. --- .github/workflows/docker-auto-test.yaml | 9 ----- backend/Dockerfile | 44 ++++++++++++++----------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 5b11e92af..30c21c1dc 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -51,15 +51,6 @@ jobs: run: | sed -i 's/: true/: "true"/g; s/: false/: "false"/g' docker-compose.yml - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-docker-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-docker-${{ github.ref_name }} - ${{ runner.os }}-docker- - - name: Build and start services run: | docker-compose build diff --git a/backend/Dockerfile b/backend/Dockerfile index 749325463..2f863e90b 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,31 +1,38 @@ # Base stage for common setup FROM python:3.11-slim-bullseye as base -# Install build dependencies and Poetry in one step to minimize layers -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc \ - && pip install --no-cache-dir poetry==1.6.1 \ - && poetry config virtualenvs.create false \ - && apt-get purge -y gcc \ - && rm -rf /var/lib/apt/lists/* - -# Set work directory -WORKDIR /app +RUN apt-get update && apt-get install -y \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install poetry==1.6.1 -# Copy only dependency files first (to leverage caching) +# Configuring poetry +RUN poetry config virtualenvs.create false + +# Copying requirements of a project COPY pyproject.toml poetry.lock /app/ +WORKDIR /app -# Install only main dependencies -RUN poetry install --only main --no-root +# Installing requirements +RUN poetry install --only main -# Copy the rest of the application files +# Removing gcc +RUN apt-get purge -y \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +# Copying the actual application, wait-for-it script, and prestart script COPY . /app/ -# Make necessary scripts executable +# Note: We mount the local directory using docker-compose so ensure these scripts also have execute permissions +# by running the following command on your host machine from the root of this project: +# chmod +x ./backend/wait-for-it.sh ./backend/lcfs/prestart.sh ./backend/lcfs/start.sh ./backend/lcfs/start-reload.sh + +# Make all startup scripts executable RUN chmod +x /app/wait-for-it.sh /app/lcfs/prestart.sh /app/lcfs/start.sh -# Default startup command -CMD ["/bin/bash", "/app/lcfs/start.sh"] +CMD /bin/bash /app/lcfs/start.sh # Production stage FROM base as prod @@ -36,6 +43,5 @@ ENV APP_ENVIRONMENT=prod FROM base as dev # Set the APP_ENVIRONMENT variable to 'development' ENV APP_ENVIRONMENT=dev - # Install additional dependencies for development -RUN poetry install --no-root +RUN poetry install From 8d17b43df67e2289cbb7d932ecddb2a2182dec9b Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 12:12:34 -0800 Subject: [PATCH 07/17] parallelize tests --- .github/workflows/docker-auto-test.yaml | 2 +- backend/poetry.lock | 46 +++++++++++++++++++++---- backend/pyproject.toml | 1 + 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 30c21c1dc..0c47293b0 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -61,7 +61,7 @@ jobs: continue-on-error: true run: | cd backend - poetry run pytest --junitxml=pytest-results.xml + poetry run pytest -n auto --junitxml=pytest-results.xml env: LCFS_DB_HOST: localhost LCFS_DB_PORT: 5432 diff --git a/backend/poetry.lock b/backend/poetry.lock index 30bf2f4bf..146fc519d 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "aio-pika" @@ -306,8 +306,8 @@ files = [ jmespath = ">=0.7.1,<2.0.0" python-dateutil = ">=2.1,<3.0.0" urllib3 = [ - {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""}, {version = ">=1.25.4,<1.27", markers = "python_version < \"3.10\""}, + {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""}, ] [package.extras] @@ -835,6 +835,20 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "2.1.1" +description = "execnet: rapid multi-Python deployment" +optional = false +python-versions = ">=3.8" +files = [ + {file = "execnet-2.1.1-py3-none-any.whl", hash = "sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc"}, + {file = "execnet-2.1.1.tar.gz", hash = "sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3"}, +] + +[package.extras] +testing = ["hatch", "pre-commit", "pytest", "tox"] + [[package]] name = "fakeredis" version = "2.26.1" @@ -2113,9 +2127,9 @@ files = [ [package.dependencies] numpy = [ - {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, {version = ">=1.22.4", markers = "python_version < \"3.11\""}, {version = ">=1.23.2", markers = "python_version == \"3.11\""}, + {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -2504,8 +2518,8 @@ annotated-types = ">=0.6.0" email-validator = {version = ">=2.0.0", optional = true, markers = "extra == \"email\""} pydantic-core = "2.23.4" typing-extensions = [ - {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, {version = ">=4.6.1", markers = "python_version < \"3.13\""}, + {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, ] [package.extras] @@ -2749,6 +2763,26 @@ pytest = ">=7.3.1" [package.extras] test = ["coverage (>=7.2.7)", "pytest-mock (>=3.10)"] +[[package]] +name = "pytest-xdist" +version = "3.6.1" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest_xdist-3.6.1-py3-none-any.whl", hash = "sha256:9ed4adfb68a016610848639bb7e02c9352d5d9f03d04809919e2dafc3be4cca7"}, + {file = "pytest_xdist-3.6.1.tar.gz", hash = "sha256:ead156a4db231eec769737f57668ef58a2084a34b2e55c4a8fa20d861107300d"}, +] + +[package.dependencies] +execnet = ">=2.1" +pytest = ">=7.0.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -3109,7 +3143,7 @@ files = [ ] [package.dependencies] -greenlet = {version = "!=0.4.17", optional = true, markers = "python_version < \"3.13\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\") or extra == \"asyncio\""} +greenlet = {version = "!=0.4.17", optional = true, markers = "python_version < \"3.13\" and (platform_machine == \"win32\" or platform_machine == \"WIN32\" or platform_machine == \"AMD64\" or platform_machine == \"amd64\" or platform_machine == \"x86_64\" or platform_machine == \"ppc64le\" or platform_machine == \"aarch64\") or extra == \"asyncio\""} typing-extensions = ">=4.6.0" [package.extras] @@ -3784,4 +3818,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "1898dc5b68facf49cb53d1fe98daecb39c1dc39b184d17c31d8d23a48cfce2c0" +content-hash = "55d9cb15f5685f6da727dfa156a16ac4d8085c6c6f98bec321f9e8b311bb162f" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index e40217ccb..8d64b46a2 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -46,6 +46,7 @@ python-multipart = "^0.0.18" aio-pika = "^9.4.3" jinja2 = "^3.1.4" requests = "^2.32.3" +pytest-xdist = "^3.6.1" [tool.poetry.dev-dependencies] pytest = "^8.3.3" From 8195a590972603c8b3055b27c47df66bc5997997 Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 12:18:37 -0800 Subject: [PATCH 08/17] Revert "parallelize tests" This reverts commit 8d17b43df67e2289cbb7d932ecddb2a2182dec9b. --- .github/workflows/docker-auto-test.yaml | 2 +- backend/poetry.lock | 46 ++++--------------------- backend/pyproject.toml | 1 - 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 0c47293b0..30c21c1dc 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -61,7 +61,7 @@ jobs: continue-on-error: true run: | cd backend - poetry run pytest -n auto --junitxml=pytest-results.xml + poetry run pytest --junitxml=pytest-results.xml env: LCFS_DB_HOST: localhost LCFS_DB_PORT: 5432 diff --git a/backend/poetry.lock b/backend/poetry.lock index 146fc519d..30bf2f4bf 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "aio-pika" @@ -306,8 +306,8 @@ files = [ jmespath = ">=0.7.1,<2.0.0" python-dateutil = ">=2.1,<3.0.0" urllib3 = [ - {version = ">=1.25.4,<1.27", markers = "python_version < \"3.10\""}, {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""}, + {version = ">=1.25.4,<1.27", markers = "python_version < \"3.10\""}, ] [package.extras] @@ -835,20 +835,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "execnet" -version = "2.1.1" -description = "execnet: rapid multi-Python deployment" -optional = false -python-versions = ">=3.8" -files = [ - {file = "execnet-2.1.1-py3-none-any.whl", hash = "sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc"}, - {file = "execnet-2.1.1.tar.gz", hash = "sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3"}, -] - -[package.extras] -testing = ["hatch", "pre-commit", "pytest", "tox"] - [[package]] name = "fakeredis" version = "2.26.1" @@ -2127,9 +2113,9 @@ files = [ [package.dependencies] numpy = [ + {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, {version = ">=1.22.4", markers = "python_version < \"3.11\""}, {version = ">=1.23.2", markers = "python_version == \"3.11\""}, - {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -2518,8 +2504,8 @@ annotated-types = ">=0.6.0" email-validator = {version = ">=2.0.0", optional = true, markers = "extra == \"email\""} pydantic-core = "2.23.4" typing-extensions = [ - {version = ">=4.6.1", markers = "python_version < \"3.13\""}, {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, + {version = ">=4.6.1", markers = "python_version < \"3.13\""}, ] [package.extras] @@ -2763,26 +2749,6 @@ pytest = ">=7.3.1" [package.extras] test = ["coverage (>=7.2.7)", "pytest-mock (>=3.10)"] -[[package]] -name = "pytest-xdist" -version = "3.6.1" -description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pytest_xdist-3.6.1-py3-none-any.whl", hash = "sha256:9ed4adfb68a016610848639bb7e02c9352d5d9f03d04809919e2dafc3be4cca7"}, - {file = "pytest_xdist-3.6.1.tar.gz", hash = "sha256:ead156a4db231eec769737f57668ef58a2084a34b2e55c4a8fa20d861107300d"}, -] - -[package.dependencies] -execnet = ">=2.1" -pytest = ">=7.0.0" - -[package.extras] -psutil = ["psutil (>=3.0)"] -setproctitle = ["setproctitle"] -testing = ["filelock"] - [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -3143,7 +3109,7 @@ files = [ ] [package.dependencies] -greenlet = {version = "!=0.4.17", optional = true, markers = "python_version < \"3.13\" and (platform_machine == \"win32\" or platform_machine == \"WIN32\" or platform_machine == \"AMD64\" or platform_machine == \"amd64\" or platform_machine == \"x86_64\" or platform_machine == \"ppc64le\" or platform_machine == \"aarch64\") or extra == \"asyncio\""} +greenlet = {version = "!=0.4.17", optional = true, markers = "python_version < \"3.13\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\") or extra == \"asyncio\""} typing-extensions = ">=4.6.0" [package.extras] @@ -3818,4 +3784,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "55d9cb15f5685f6da727dfa156a16ac4d8085c6c6f98bec321f9e8b311bb162f" +content-hash = "1898dc5b68facf49cb53d1fe98daecb39c1dc39b184d17c31d8d23a48cfce2c0" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 8d64b46a2..e40217ccb 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -46,7 +46,6 @@ python-multipart = "^0.0.18" aio-pika = "^9.4.3" jinja2 = "^3.1.4" requests = "^2.32.3" -pytest-xdist = "^3.6.1" [tool.poetry.dev-dependencies] pytest = "^8.3.3" From 799afa6368868e0a0dcd3b175bafd84aea8e4f04 Mon Sep 17 00:00:00 2001 From: Hamed Valiollahi Bayeki Date: Thu, 12 Dec 2024 13:53:08 -0800 Subject: [PATCH 09/17] fix: correct default_carbon_intensity for 'Other diesel' fuel type --- .../versions/2024-12-12-21-43_5d729face5ab.py | 35 +++++++++++++++++++ .../db/seeders/common/seed_fuel_data.json | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 backend/lcfs/db/migrations/versions/2024-12-12-21-43_5d729face5ab.py diff --git a/backend/lcfs/db/migrations/versions/2024-12-12-21-43_5d729face5ab.py b/backend/lcfs/db/migrations/versions/2024-12-12-21-43_5d729face5ab.py new file mode 100644 index 000000000..558720d38 --- /dev/null +++ b/backend/lcfs/db/migrations/versions/2024-12-12-21-43_5d729face5ab.py @@ -0,0 +1,35 @@ +"""Update default_carbon_intensity for 'Other diesel' fuel type + +Revision ID: 5d729face5ab +Revises: 7ae38a8413ab +Create Date: 2024-12-12 21:43:01.414475 +""" + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "5d729face5ab" +down_revision = "7ae38a8413ab" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.execute( + """ + UPDATE fuel_type + SET default_carbon_intensity = 100.21 + WHERE fuel_type_id = 20 + """ + ) + + +def downgrade() -> None: + op.execute( + """ + UPDATE fuel_type + SET default_carbon_intensity = 94.38 + WHERE fuel_type_id = 20 + """ + ) diff --git a/backend/lcfs/db/seeders/common/seed_fuel_data.json b/backend/lcfs/db/seeders/common/seed_fuel_data.json index bc4bf1d87..ac68f21d7 100644 --- a/backend/lcfs/db/seeders/common/seed_fuel_data.json +++ b/backend/lcfs/db/seeders/common/seed_fuel_data.json @@ -188,7 +188,7 @@ "fossil_derived": true, "other_uses_fossil_derived": true, "provision_1_id": 1, - "default_carbon_intensity": 94.38, + "default_carbon_intensity": 100.21, "units": "L", "unrecognized": false } From ad157c144b8146068989caeb3c624114770749cc Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 13:56:26 -0800 Subject: [PATCH 10/17] finalize --- backend/test.txt | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 backend/test.txt diff --git a/backend/test.txt b/backend/test.txt deleted file mode 100644 index 742cf3868..000000000 --- a/backend/test.txt +++ /dev/null @@ -1,2 +0,0 @@ -testing workflow, remove after testing. -update to app files. \ No newline at end of file From 1f21cc6589f4184eb954d958a75afbe0eab48124 Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 14:01:59 -0800 Subject: [PATCH 11/17] update --- .github/workflows/docker-auto-test.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 30c21c1dc..e690e70ff 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -47,14 +47,18 @@ jobs: poetry install pip install pytest-github-actions-annotate-failures typing_extensions - - name: Fix docker-compose.yml + - name: Modify docker-compose.yml run: | - sed -i 's/: true/: "true"/g; s/: false/: "false"/g' docker-compose.yml + sed -i '/minio:/,/depends_on:/d' docker-compose.yml + sed -i '/create_bucket:/,/depends_on:/d' docker-compose.yml + sed -i '/frontend:/,/networks:/d' docker-compose.yml + sed -i 's/create_bucket,//g' + sed -i 's/frontend,//g' - name: Build and start services run: | docker-compose build - docker-compose up -d + docker-compose up -d db redis rabbitmq backend - name: Run backend tests id: backend_tests From 33a3c0d724bcda86f243ed689aeaaede84091db8 Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 14:05:42 -0800 Subject: [PATCH 12/17] . --- .github/workflows/docker-auto-test.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index e690e70ff..a0b650155 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -49,6 +49,7 @@ jobs: - name: Modify docker-compose.yml run: | + sed -i 's/: true/: "true"/g; s/: false/: "false"/g' docker-compose.yml sed -i '/minio:/,/depends_on:/d' docker-compose.yml sed -i '/create_bucket:/,/depends_on:/d' docker-compose.yml sed -i '/frontend:/,/networks:/d' docker-compose.yml @@ -58,7 +59,7 @@ jobs: - name: Build and start services run: | docker-compose build - docker-compose up -d db redis rabbitmq backend + docker-compose up -d - name: Run backend tests id: backend_tests From 882a3819c461890c8b9c48b0f9d9f9e5d438e300 Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 14:07:31 -0800 Subject: [PATCH 13/17] . --- .github/workflows/docker-auto-test.yaml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index a0b650155..837d2d171 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -18,11 +18,6 @@ jobs: with: python-version: "3.10.13" - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "20" - - name: Install Docker Compose run: | sudo apt-get update @@ -47,14 +42,9 @@ jobs: poetry install pip install pytest-github-actions-annotate-failures typing_extensions - - name: Modify docker-compose.yml + - name: Fix docker-compose.yml run: | sed -i 's/: true/: "true"/g; s/: false/: "false"/g' docker-compose.yml - sed -i '/minio:/,/depends_on:/d' docker-compose.yml - sed -i '/create_bucket:/,/depends_on:/d' docker-compose.yml - sed -i '/frontend:/,/networks:/d' docker-compose.yml - sed -i 's/create_bucket,//g' - sed -i 's/frontend,//g' - name: Build and start services run: | From b488ee95772c47fb84ecaa06c648681b07c9960d Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 14:28:11 -0800 Subject: [PATCH 14/17] . --- .github/workflows/docker-auto-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 837d2d171..fe886f335 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -49,7 +49,7 @@ jobs: - name: Build and start services run: | docker-compose build - docker-compose up -d + docker-compose up -d db redis rabbitmq backend - name: Run backend tests id: backend_tests From c2864ecea19290d7a2afab618aeb5ff9fff69f24 Mon Sep 17 00:00:00 2001 From: prv-proton Date: Thu, 12 Dec 2024 14:32:39 -0800 Subject: [PATCH 15/17] . --- .github/workflows/docker-auto-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index fe886f335..837d2d171 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -49,7 +49,7 @@ jobs: - name: Build and start services run: | docker-compose build - docker-compose up -d db redis rabbitmq backend + docker-compose up -d - name: Run backend tests id: backend_tests From ec5620a7ed892d50b49f499ea315a815cea115cf Mon Sep 17 00:00:00 2001 From: Kevin Hashimoto Date: Thu, 12 Dec 2024 14:59:08 -0800 Subject: [PATCH 16/17] feat: clickable summaries --- .../AllocationAgreementSummary.jsx | 17 +++++++++--- .../FinalSupplyEquipmentSummary.jsx | 26 ++++++++++++++----- .../views/FuelExports/FuelExportSummary.jsx | 16 ++++++++++-- .../views/FuelSupplies/FuelSupplySummary.jsx | 17 +++++++++--- .../NotionalTransferSummary.jsx | 18 +++++++++++-- .../src/views/OtherUses/OtherUsesSummary.jsx | 23 +++++++++++++--- 6 files changed, 97 insertions(+), 20 deletions(-) diff --git a/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx b/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx index 7e76706cf..30b1a9f02 100644 --- a/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx +++ b/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx @@ -1,23 +1,24 @@ import BCAlert from '@/components/BCAlert' import BCBox from '@/components/BCBox' import BCDataGridServer from '@/components/BCDataGrid/BCDataGridServer' -import { apiRoutes } from '@/constants/routes' +import { apiRoutes, ROUTES } from '@/constants/routes' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters' import { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { useLocation, useParams } from 'react-router-dom' +import { useLocation, useParams, useNavigate } from 'react-router-dom' import { v4 as uuid } from 'uuid' export const AllocationAgreementSummary = ({ data }) => { const [alertMessage, setAlertMessage] = useState('') const [alertSeverity, setAlertSeverity] = useState('info') const [gridKey, setGridKey] = useState(`allocation-agreements-grid`) - const { complianceReportId } = useParams() + const { complianceReportId, compliancePeriod } = useParams() const gridRef = useRef() const { t } = useTranslation(['common', 'allocationAgreement']) const location = useLocation() + const navigate = useNavigate() useEffect(() => { if (location.state?.message) { @@ -135,6 +136,15 @@ export const AllocationAgreementSummary = ({ data }) => { setGridKey(`allocation-agreements-grid-${uuid()}`) } + const handleRowClicked = (params) => { + navigate( + ROUTES.REPORTS_ADD_ALLOCATION_AGREEMENTS.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + return (
@@ -159,6 +169,7 @@ export const AllocationAgreementSummary = ({ data }) => { enableCopyButton={false} defaultColDef={defaultColDef} suppressPagination={data.allocationAgreements.length <= 10} + handleRowClicked={handleRowClicked} /> diff --git a/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx b/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx index 1a2f7851e..4753dc1fc 100644 --- a/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx +++ b/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx @@ -1,23 +1,24 @@ import BCAlert from '@/components/BCAlert' import BCBox from '@/components/BCBox' import BCDataGridServer from '@/components/BCDataGrid/BCDataGridServer' -import { apiRoutes } from '@/constants/routes' +import { apiRoutes, ROUTES } from '@/constants/routes' import { CommonArrayRenderer } from '@/utils/grid/cellRenderers' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' import { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { useLocation, useParams } from 'react-router-dom' +import { useLocation, useParams, useNavigate } from 'react-router-dom' import { v4 as uuid } from 'uuid' export const FinalSupplyEquipmentSummary = ({ data }) => { const [alertMessage, setAlertMessage] = useState('') const [alertSeverity, setAlertSeverity] = useState('info') const [gridKey, setGridKey] = useState(`final-supply-equipments-grid`) - const { complianceReportId } = useParams() + const { complianceReportId, compliancePeriod } = useParams() const gridRef = useRef() const { t } = useTranslation(['common', 'finalSupplyEquipments']) const location = useLocation() + const navigate = useNavigate() useEffect(() => { if (location.state?.message) { @@ -67,9 +68,12 @@ export const FinalSupplyEquipmentSummary = ({ data }) => { field: 'supplyToDate' }, { - headerName: t('finalSupplyEquipment:finalSupplyEquipmentColLabels.kwhUsage'), + headerName: t( + 'finalSupplyEquipment:finalSupplyEquipmentColLabels.kwhUsage' + ), field: 'kwhUsage', - valueFormatter: (params) => params.value ? params.value.toFixed(2) : '0.00' + valueFormatter: (params) => + params.value ? params.value.toFixed(2) : '0.00' }, { headerName: t( @@ -106,7 +110,7 @@ export const FinalSupplyEquipmentSummary = ({ data }) => { headerName: t( 'finalSupplyEquipment:finalSupplyEquipmentColLabels.ports' ), - field: 'ports', + field: 'ports' }, { headerName: t( @@ -183,6 +187,15 @@ export const FinalSupplyEquipmentSummary = ({ data }) => { setGridKey(`final-supply-equipments-grid-${uuid()}`) } + const handleRowClicked = (params) => { + navigate( + ROUTES.REPORTS_ADD_FINAL_SUPPLY_EQUIPMENTS.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + return (
@@ -207,6 +220,7 @@ export const FinalSupplyEquipmentSummary = ({ data }) => { enableCopyButton={false} defaultColDef={defaultColDef} suppressPagination={data.finalSupplyEquipments.length <= 10} + handleRowClicked={handleRowClicked} /> diff --git a/frontend/src/views/FuelExports/FuelExportSummary.jsx b/frontend/src/views/FuelExports/FuelExportSummary.jsx index 03f2f06d5..4cab9c377 100644 --- a/frontend/src/views/FuelExports/FuelExportSummary.jsx +++ b/frontend/src/views/FuelExports/FuelExportSummary.jsx @@ -6,17 +6,19 @@ import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' import { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { useLocation, useParams } from 'react-router-dom' +import { useLocation, useParams, useNavigate } from 'react-router-dom' import i18n from '@/i18n' +import { ROUTES } from '@/constants/routes' export const FuelExportSummary = ({ data }) => { const [alertMessage, setAlertMessage] = useState('') const [alertSeverity, setAlertSeverity] = useState('info') - const { complianceReportId } = useParams() + const { complianceReportId, compliancePeriod } = useParams() const gridRef = useRef() const { t } = useTranslation(['common', 'fuelExport']) const location = useLocation() + const navigate = useNavigate() useEffect(() => { if (location.state?.message) { @@ -122,6 +124,15 @@ export const FuelExportSummary = ({ data }) => { return params.data.fuelExportId.toString() } + const handleRowClicked = (params) => { + navigate( + ROUTES.REPORTS_ADD_FUEL_EXPORTS.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + return (
@@ -144,6 +155,7 @@ export const FuelExportSummary = ({ data }) => { enableCopyButton={false} defaultColDef={defaultColDef} suppressPagination={data.fuelExports.length <= 10} + onRowClicked={handleRowClicked} /> diff --git a/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx b/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx index a8ea2298c..2e913d8dd 100644 --- a/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx +++ b/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx @@ -1,12 +1,12 @@ import BCAlert from '@/components/BCAlert' import BCBox from '@/components/BCBox' import BCDataGridServer from '@/components/BCDataGrid/BCDataGridServer' -import { apiRoutes } from '@/constants/routes' +import { apiRoutes, ROUTES } from '@/constants/routes' import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' import { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { useLocation, useParams } from 'react-router-dom' +import { useLocation, useNavigate, useParams } from 'react-router-dom' import { v4 as uuid } from 'uuid' import i18n from '@/i18n' import { StandardCellWarningAndErrors } from '@/utils/grid/errorRenderers' @@ -15,11 +15,12 @@ export const FuelSupplySummary = ({ data }) => { const [alertMessage, setAlertMessage] = useState('') const [alertSeverity, setAlertSeverity] = useState('info') const [gridKey, setGridKey] = useState(`fuel-supplies-grid`) - const { complianceReportId } = useParams() + const { complianceReportId, compliancePeriod } = useParams() const gridRef = useRef() const { t } = useTranslation(['common', 'fuelSupply']) const location = useLocation() + const navigate = useNavigate() useEffect(() => { if (location.state?.message) { @@ -125,6 +126,15 @@ export const FuelSupplySummary = ({ data }) => { setGridKey(`fuel-supplies-grid-${uuid()}`) } + const handleRowClicked = (params) => { + navigate( + ROUTES.REPORTS_ADD_SUPPLY_OF_FUEL.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + return (
@@ -149,6 +159,7 @@ export const FuelSupplySummary = ({ data }) => { enableCopyButton={false} defaultColDef={defaultColDef} suppressPagination={data.fuelSupplies.length <= 10} + handleRowClicked={handleRowClicked} /> diff --git a/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx b/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx index 1cc1c5017..e93d2502f 100644 --- a/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx +++ b/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx @@ -5,16 +5,18 @@ import { useGetNotionalTransfers } from '@/hooks/useNotionalTransfer' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' import { useEffect, useState, useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { useLocation, useParams } from 'react-router-dom' +import { useLocation, useParams, useNavigate } from 'react-router-dom' import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters' +import { ROUTES } from '@/constants/routes' export const NotionalTransferSummary = ({ data }) => { const [alertMessage, setAlertMessage] = useState('') const [alertSeverity, setAlertSeverity] = useState('info') - const { complianceReportId } = useParams() + const { complianceReportId, compliancePeriod } = useParams() const { t } = useTranslation(['common', 'notionalTransfers']) const location = useLocation() + const navigate = useNavigate() useEffect(() => { if (location.state?.message) { @@ -32,6 +34,16 @@ export const NotionalTransferSummary = ({ data }) => { [] ) + const handleRowClicked = (params) => { + console.log('Row clicked', params) + navigate( + ROUTES.REPORTS_ADD_NOTIONAL_TRANSFERS.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + const columns = [ { headerName: t('notionalTransfer:notionalTransferColLabels.legalName'), @@ -90,6 +102,8 @@ export const NotionalTransferSummary = ({ data }) => { }} enableCellTextSelection ensureDomOrder + handleRo + onRowClicked={handleRowClicked} /> diff --git a/frontend/src/views/OtherUses/OtherUsesSummary.jsx b/frontend/src/views/OtherUses/OtherUsesSummary.jsx index bd5f2b499..7c8020739 100644 --- a/frontend/src/views/OtherUses/OtherUsesSummary.jsx +++ b/frontend/src/views/OtherUses/OtherUsesSummary.jsx @@ -4,18 +4,23 @@ import { BCGridViewer } from '@/components/BCDataGrid/BCGridViewer' import { useGetOtherUses } from '@/hooks/useOtherUses' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' import { useEffect, useState } from 'react' -import { useLocation, useParams } from 'react-router-dom' -import { formatNumberWithCommas as valueFormatter, decimalFormatter } from '@/utils/formatters' +import { useLocation, useParams, useNavigate } from 'react-router-dom' +import { + formatNumberWithCommas as valueFormatter, + decimalFormatter +} from '@/utils/formatters' import { useTranslation } from 'react-i18next' +import { ROUTES } from '@/constants/routes' export const OtherUsesSummary = ({ data }) => { const [alertMessage, setAlertMessage] = useState('') const [alertSeverity, setAlertSeverity] = useState('info') const { t } = useTranslation(['common', 'otherUses']) - const { complianceReportId } = useParams() + const { complianceReportId, compliancePeriod } = useParams() const location = useLocation() + const navigate = useNavigate() useEffect(() => { if (location.state?.message) { @@ -81,6 +86,15 @@ export const OtherUsesSummary = ({ data }) => { const getRowId = (params) => params.data.otherUsesId + const handleRowClicked = (params) => { + navigate( + ROUTES.REPORTS_ADD_OTHER_USE_FUELS.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + return (
@@ -106,10 +120,11 @@ export const OtherUsesSummary = ({ data }) => { }} enableCellTextSelection ensureDomOrder + onRowClicked={handleRowClicked} /> ) } -OtherUsesSummary.displayName = 'OtherUsesSummary' \ No newline at end of file +OtherUsesSummary.displayName = 'OtherUsesSummary' From 2552cdf74f02153d577cfbdf603ddbe4175d8849 Mon Sep 17 00:00:00 2001 From: Kuan Fan Date: Mon, 16 Dec 2024 15:42:03 -0800 Subject: [PATCH 17/17] cache oc command --- .github/workflows/dev-ci.yml | 33 +++++++++++++++++++++ .github/workflows/pr-build.yaml | 46 ++++++++++++++++++++++++++++++ .github/workflows/pr-teardown.yaml | 32 +++++++++++++++++++++ .github/workflows/prod-ci.yaml | 32 +++++++++++++++++++++ .github/workflows/test-ci.yaml | 33 +++++++++++++++++++++ 5 files changed, 176 insertions(+) diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml index ac8071561..6de1db940 100644 --- a/.github/workflows/dev-ci.yml +++ b/.github/workflows/dev-ci.yml @@ -23,9 +23,36 @@ concurrency: jobs: + install-oc: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + + - name: Set up cache for OpenShift CLI + id: cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc # Path where the `oc` binary will be installed + key: oc-cli-${{ runner.os }} + + - name: Install OpenShift CLI (if not cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz + tar -xvf openshift-client-linux.tar.gz + sudo mv oc /usr/local/bin/ + oc version --client + + - name: Confirm OpenShift CLI is Available + run: oc version --client + set-pre-release: name: Calculate pre-release number runs-on: ubuntu-latest + needs: [install-oc] outputs: output1: ${{ steps.set-pre-release.outputs.PRE_RELEASE }} @@ -49,6 +76,12 @@ jobs: - name: Check out repository uses: actions/checkout@v4.1.1 + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} + - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml index f351a91c5..7086a5834 100644 --- a/.github/workflows/pr-build.yaml +++ b/.github/workflows/pr-build.yaml @@ -19,17 +19,51 @@ concurrency: cancel-in-progress: true jobs: + install-oc: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + + - name: Set up cache for OpenShift CLI + id: cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc # Path where the `oc` binary will be installed + key: oc-cli-${{ runner.os }} + + - name: Install OpenShift CLI (if not cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz + tar -xvf openshift-client-linux.tar.gz + sudo mv oc /usr/local/bin/ + oc version --client + + - name: Confirm OpenShift CLI is Available + run: oc version --client + get-version: if: > (github.event.action == 'labeled' && github.event.label.name == 'build' && github.event.pull_request.base.ref == github.event.repository.default_branch) || (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'build') && github.event.pull_request.base.ref == github.event.repository.default_branch) name: Retrieve version runs-on: ubuntu-latest + needs: [install-oc] outputs: output1: ${{ steps.get-version.outputs.VERSION }} steps: + + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} + - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: @@ -69,6 +103,12 @@ jobs: with: ref: ${{ github.event.pull_request.head.ref }} + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} + - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: @@ -123,6 +163,12 @@ jobs: ref: main ssh-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }} + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} + - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: diff --git a/.github/workflows/pr-teardown.yaml b/.github/workflows/pr-teardown.yaml index 783c221a8..201c08e04 100644 --- a/.github/workflows/pr-teardown.yaml +++ b/.github/workflows/pr-teardown.yaml @@ -13,6 +13,31 @@ concurrency: cancel-in-progress: true jobs: + install-oc: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + + - name: Set up cache for OpenShift CLI + id: cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc # Path where the `oc` binary will be installed + key: oc-cli-${{ runner.os }} + + - name: Install OpenShift CLI (if not cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz + tar -xvf openshift-client-linux.tar.gz + sudo mv oc /usr/local/bin/ + oc version --client + + - name: Confirm OpenShift CLI is Available + run: oc version --client teardown: if: > @@ -20,9 +45,16 @@ jobs: (github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'build') ) name: PR Teardown runs-on: ubuntu-latest + needs: [install-oc] timeout-minutes: 60 steps: + + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 diff --git a/.github/workflows/prod-ci.yaml b/.github/workflows/prod-ci.yaml index 3478be8ff..b3a1eab61 100644 --- a/.github/workflows/prod-ci.yaml +++ b/.github/workflows/prod-ci.yaml @@ -14,12 +14,38 @@ concurrency: cancel-in-progress: true jobs: + install-oc: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + + - name: Set up cache for OpenShift CLI + id: cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc # Path where the `oc` binary will be installed + key: oc-cli-${{ runner.os }} + + - name: Install OpenShift CLI (if not cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz + tar -xvf openshift-client-linux.tar.gz + sudo mv oc /usr/local/bin/ + oc version --client + + - name: Confirm OpenShift CLI is Available + run: oc version --client # Read the image tag from test environment get-image-tag: name: Get the image-tag from values-test.yaml runs-on: ubuntu-latest + needs: [install-oc] outputs: IMAGE_TAG: ${{ steps.get-image-tag.outputs.IMAGE_TAG }} @@ -84,6 +110,12 @@ jobs: approvers: AlexZorkin,kuanfandevops,hamed-valiollahi,airinggov,areyeslo,dhaselhan,Grulin minimum-approvals: 2 issue-title: "LCFS ${{env.IMAGE_TAG }} Prod Deployment at ${{ env.CURRENT_TIME }}." + + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 diff --git a/.github/workflows/test-ci.yaml b/.github/workflows/test-ci.yaml index 1119b9432..80d6690f2 100644 --- a/.github/workflows/test-ci.yaml +++ b/.github/workflows/test-ci.yaml @@ -14,9 +14,36 @@ concurrency: cancel-in-progress: true jobs: + install-oc: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + + - name: Set up cache for OpenShift CLI + id: cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc # Path where the `oc` binary will be installed + key: oc-cli-${{ runner.os }} + + - name: Install OpenShift CLI (if not cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz + tar -xvf openshift-client-linux.tar.gz + sudo mv oc /usr/local/bin/ + oc version --client + + - name: Confirm OpenShift CLI is Available + run: oc version --client + run-tests: name: Run Tests runs-on: ubuntu-latest + needs: [install-oc] steps: - uses: actions/checkout@v3 @@ -229,6 +256,12 @@ jobs: minimum-approvals: 1 issue-title: "LCFS ${{ env.VERSION }}-${{ env.PRE_RELEASE }} Test Deployment" + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} + - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: