Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-0.2.0' into fix/kevin-1400
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-hashimoto committed Dec 11, 2024
2 parents e965289 + 68ccf7a commit 44a03ec
Show file tree
Hide file tree
Showing 73 changed files with 1,401 additions and 524 deletions.
167 changes: 43 additions & 124 deletions .github/workflows/docker-auto-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ on:
- "*"

jobs:
build-and-test:
backend-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -37,14 +36,6 @@ jobs:
restore-keys: |
${{ runner.os }}-poetry-
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Docker images
uses: actions/cache@v3
with:
Expand All @@ -53,30 +44,17 @@ jobs:
restore-keys: |
${{ runner.os }}-docker-
# Commented out mochawesome installation as it's only needed for Cypress
# - name: Install mochawesome and marge
# run: |
# npm install mochawesome mochawesome-merge mochawesome-report-generator --save-dev

- name: Install Poetry
run: pip install poetry==1.6.1

- name: Install backend dependencies
run: |
# Ensure that pip, setuptools, and wheel are up to date
pip install --upgrade pip setuptools wheel
# Install Poetry dependencies
cd backend
poetry config virtualenvs.create false
poetry install
pip install pytest-github-actions-annotate-failures typing_extensions
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Fix docker-compose.yml
run: |
sed -i 's/: true/: "true"/g; s/: false/: "false"/g' docker-compose.yml
Expand Down Expand Up @@ -110,94 +88,6 @@ jobs:
name: pytest-results
path: backend/pytest-results.xml

- name: Run frontend tests
id: frontend_tests
continue-on-error: true
run: |
cd frontend
npm run test:run -- --reporter=junit --outputFile=vitest-results.xml
env:
CI: true

- name: Upload Vitest results
if: always()
uses: actions/upload-artifact@v4
with:
name: vitest-results
path: frontend/vitest-results.xml

# Commented out Cypress-related steps
# - name: Create cypress.env.json
# run: |
# echo '{
# "admin_idir_username": "${{ secrets.ADMIN_IDIR_USERNAME }}",
# "admin_idir_password": "${{ secrets.ADMIN_IDIR_PASSWORD }}",
# "org1_bceid_username": "${{ secrets.ORG1_BCEID_USERNAME }}",
# "org1_bceid_password": "${{ secrets.ORG1_BCEID_PASSWORD }}",
# "org1_bceid_id": "${{ secrets.ORG1_BCEID_ID }}",
# "org1_bceid_userId": "${{ secrets.ORG1_BCEID_USERID }}",
# "org2_bceid_username": "${{ secrets.ORG2_BCEID_USERNAME }}",
# "org2_bceid_password": "${{ secrets.ORG2_BCEID_PASSWORD }}",
# "org2_bceid_id": "${{ secrets.ORG2_BCEID_ID }}",
# "org2_bceid_userId": "${{ secrets.ORG2_BCEID_USERID }}"
# }' > frontend/cypress.env.json

# - name: Run Cypress tests
# id: cypress_tests
# continue-on-error: true
# uses: cypress-io/github-action@v6
# with:
# command: npm run cypress:run
# wait-on: 'http://localhost:3000'
# working-directory: frontend
# env:
# ADMIN_IDIR_USERNAME: ${{ secrets.ADMIN_IDIR_USERNAME }}
# ADMIN_IDIR_PASSWORD: ${{ secrets.ADMIN_IDIR_PASSWORD }}
# org1_bceid_username: ${{ secrets.ORG1_BCEID_USERNAME }}
# org1_bceid_password: ${{ secrets.ORG1_BCEID_PASSWORD }}
# org1_bceid_id: ${{ secrets.ORG1_BCEID_ID }}
# org1_bceid_userId: ${{ secrets.ORG1_BCEID_USERID }}
# org2_bceid_username: ${{ secrets.ORG2_BCEID_USERNAME }}
# org2_bceid_password: ${{ secrets.ORG2_BCEID_PASSWORD }}
# org2_bceid_id: ${{ secrets.ORG2_BCEID_ID }}
# org2_bceid_userId: ${{ secrets.ORG2_BCEID_USERID }}

# - name: Combine mochawesome reports
# run: |
# npx mochawesome-merge frontend/cypress/reports/*.json > frontend/cypress/reports/combined-report.json

# - name: Generate HTML report
# run: |
# npx marge frontend/cypress/reports/combined-report.json --reportDir frontend/cypress/reports --inline

# - name: Generate test summary
# run: |
# node generate-summary.js

# - name: Post test summary as a comment
# if: always()
# run: |
# SUMMARY=$(cat frontend/cypress/reports/test-summary.txt)
# gh pr comment ${{ github.event.pull_request.number }} --body "$SUMMARY"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Upload Cypress results
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: cypress-results
# path: |
# frontend/cypress/reports/
# frontend/cypress/screenshots/

# - name: Post Cypress results as a comment
# if: always()
# run: |
# gh pr comment ${{ github.event.pull_request.number }} --body "Cypress test report is available [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). Download the 'cypress-results' artifact to view the report."
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Stop services
if: always()
run: docker-compose down
Expand All @@ -214,6 +104,48 @@ jobs:
report_individual_runs: "true"
deduplicate_classes_by_file_name: "true"


frontend-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Run frontend tests
id: frontend_tests
continue-on-error: true
run: |
cd frontend
npm run test:run -- --reporter=junit --outputFile=vitest-results.xml
env:
CI: true

- name: Upload Vitest results
if: always()
uses: actions/upload-artifact@v4
with:
name: vitest-results
path: frontend/vitest-results.xml

- name: Publish Frontend Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
Expand All @@ -225,16 +157,3 @@ jobs:
fail_on: "errors"
report_individual_runs: "true"
deduplicate_classes_by_file_name: "true"

- name: Check test results
if: always()
run: |
if [ "${{ steps.backend_tests.outcome }}" == "failure" ] || \
[ "${{ steps.frontend_tests.outcome }}" == "failure" ]; then
# Note: When re-enabling Cypress tests, add this condition:
# || [ "${{ steps.cypress_tests.outcome }}" == "failure" ]
echo "One or more tests failed"
exit 1
else
echo "All tests passed"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Add Organization name to FSE
Revision ID: 9206124a098b
Revises: aeaa26f5cdd5
Create Date: 2024-12-04 09:59:22.876386
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '9206124a098b'
down_revision = '26ab15f8ab18'
branch_labels = None
depends_on = None


def upgrade():
# Add the column 'organization_name' to 'final_supply_equipment' table
op.add_column("final_supply_equipment", sa.Column("organization_name", sa.String(), nullable=True))


def downgrade():
# Remove the column 'organization_name' from 'final_supply_equipment' table
op.drop_column("final_supply_equipment", "organization_name")
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# revision identifiers, used by Alembic.
revision = "cd8698fe40e6"
down_revision = "26ab15f8ab18"
down_revision = "9206124a098b"
branch_labels = None
depends_on = None

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""Update Fuel Types measured in volume to be other-uses
Revision ID: 7ae38a8413ab
Revises: 26ab15f8ab18
Create Date: 2024-12-09 19:31:18.199089
"""

import sqlalchemy as sa
from alembic import op
from datetime import datetime

# revision identifiers, used by Alembic.
revision = "7ae38a8413ab"
down_revision = "cd8698fe40e6"
branch_labels = None
depends_on = None


def upgrade() -> None:
current_time = datetime.now()

# Update the `other_uses_fossil_derived` field for all specified fuel types
op.execute(
f"""
UPDATE fuel_type
SET other_uses_fossil_derived = true,
update_date = '{current_time}',
update_user = 'no_user'
WHERE fuel_type IN (
'Alternative jet fuel',
'Biodiesel',
'Ethanol',
'HDRD',
'Renewable gasoline',
'Renewable naphtha'
)
"""
)

# Update the `other_uses_fossil_derived` field for all specified fuel types
op.execute(
f"""
UPDATE fuel_type
SET other_uses_fossil_derived = false,
update_date = '{current_time}',
update_user = 'no_user'
WHERE fuel_type IN (
'CNG',
'Electricity',
'Hydrogen',
'LNG',
'Propane'
)
"""
)


def downgrade() -> None:
current_time = datetime.now()

# Revert the `other_uses_fossil_derived` field to false for the first set of fuel types
op.execute(
f"""
UPDATE fuel_type
SET other_uses_fossil_derived = false,
update_date = '{current_time}',
update_user = 'no_user'
WHERE fuel_type IN (
'Alternative jet fuel',
'Biodiesel',
'Ethanol',
'HDRD',
'Renewable gasoline',
'Renewable naphtha'
)
"""
)

# Revert the `other_uses_fossil_derived` field to true for the second set of fuel types
op.execute(
f"""
UPDATE fuel_type
SET other_uses_fossil_derived = true,
update_date = '{current_time}',
update_user = 'no_user'
WHERE fuel_type IN (
'CNG',
'Electricity',
'Hydrogen',
'LNG',
'Propane'
)
"""
)
1 change: 1 addition & 0 deletions backend/lcfs/db/models/compliance/FinalSupplyEquipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class FinalSupplyEquipment(BaseModel, Auditable):
Double, nullable=False, comment="The longitude of the equipment location."
)
notes = Column(Text, comment="Any additional notes related to the equipment.")
organization_name = Column(Text, comment="External organization name.")

# relationships
compliance_report = relationship(
Expand Down
Loading

0 comments on commit 44a03ec

Please sign in to comment.