From 3cb28c5247334fef37169efdfc4a82bbcd17f386 Mon Sep 17 00:00:00 2001 From: Anis SMAIL Date: Wed, 29 Jan 2025 15:57:02 +0100 Subject: [PATCH] wip --- .github/workflows/main.yml | 192 +++++++++++++++++----------------- antarest/study/model.py | 7 +- tests/storage/test_service.py | 2 +- 3 files changed, 102 insertions(+), 99 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b6eaff423f..a5207a3d20 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: strategy: max-parallel: 9 matrix: - os: [windows-latest] + os: [windows-latest, ubuntu-20.04] steps: - name: Checkout github repo (+ download lfs dependencies) @@ -61,102 +61,102 @@ jobs: name: python-code-coverage-report path: coverage.xml - # npm-setup: - # runs-on: ubuntu-20.04 - # steps: - # - name: Checkout github repo - # uses: actions/checkout@v4 - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: 22.13.0 - # - name: Cache node modules - # uses: actions/cache@v4 - # with: - # path: webapp/node_modules - # key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} - # restore-keys: | - # ${{ runner.os }}-webapp-node-modules- - # ${{ runner.os }}- - # save-always: true - # - name: Install dependencies - # run: npm install - # working-directory: webapp + npm-setup: + runs-on: ubuntu-20.04 + steps: + - name: Checkout github repo + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.13.0 + - name: Cache node modules + uses: actions/cache@v4 + with: + path: webapp/node_modules + key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-webapp-node-modules- + ${{ runner.os }}- + save-always: true + - name: Install dependencies + run: npm install + working-directory: webapp - # npm-lint: - # needs: npm-setup - # runs-on: ubuntu-20.04 - # steps: - # - name: Checkout github repo - # uses: actions/checkout@v4 - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: 22.13.0 - # - name: Restore node modules - # uses: actions/cache@v4 - # with: - # path: webapp/node_modules - # key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} - # save-always: true - # - name: Lint - # run: npm run lint - # working-directory: webapp + npm-lint: + needs: npm-setup + runs-on: ubuntu-20.04 + steps: + - name: Checkout github repo + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.13.0 + - name: Restore node modules + uses: actions/cache@v4 + with: + path: webapp/node_modules + key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} + save-always: true + - name: Lint + run: npm run lint + working-directory: webapp - # npm-test: - # needs: npm-setup - # runs-on: ubuntu-20.04 - # steps: - # - name: Checkout github repo - # uses: actions/checkout@v4 - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: 22.13.0 - # - name: Restore node modules - # uses: actions/cache@v4 - # with: - # path: webapp/node_modules - # key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} - # save-always: true - # - name: Test - # run: npm run test - # working-directory: webapp + npm-test: + needs: npm-setup + runs-on: ubuntu-20.04 + steps: + - name: Checkout github repo + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.13.0 + - name: Restore node modules + uses: actions/cache@v4 + with: + path: webapp/node_modules + key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} + save-always: true + - name: Test + run: npm run test + working-directory: webapp - # npm-build: - # needs: npm-setup - # runs-on: ubuntu-20.04 - # steps: - # - name: Checkout github repo - # uses: actions/checkout@v4 - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: 22.13.0 - # - name: Restore node modules - # uses: actions/cache@v4 - # with: - # path: webapp/node_modules - # key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} - # save-always: true - # - name: Build - # run: npm run build - # working-directory: webapp - # env: - # NODE_OPTIONS: --max-old-space-size=8192 - # DISABLE_ESLINT_PLUGIN: true + npm-build: + needs: npm-setup + runs-on: ubuntu-20.04 + steps: + - name: Checkout github repo + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.13.0 + - name: Restore node modules + uses: actions/cache@v4 + with: + path: webapp/node_modules + key: ${{ runner.os }}-webapp-node-modules-${{ hashFiles('webapp/package-lock.json') }} + save-always: true + - name: Build + run: npm run build + working-directory: webapp + env: + NODE_OPTIONS: --max-old-space-size=8192 + DISABLE_ESLINT_PLUGIN: true - # sonarcloud: - # runs-on: ubuntu-20.04 - # needs: [python-test, npm-test] - # steps: - # - uses: actions/checkout@v4 - # - name: Download python coverage report - # uses: actions/download-artifact@v4 - # with: - # name: python-code-coverage-report - # - name: SonarCloud Scan - # uses: sonarsource/sonarcloud-github-action@v3.1.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + sonarcloud: + runs-on: ubuntu-20.04 + needs: [python-test, npm-test] + steps: + - uses: actions/checkout@v4 + - name: Download python coverage report + uses: actions/download-artifact@v4 + with: + name: python-code-coverage-report + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@v3.1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/antarest/study/model.py b/antarest/study/model.py index 4dca7463e8..fb65e6e47c 100644 --- a/antarest/study/model.py +++ b/antarest/study/model.py @@ -231,7 +231,7 @@ class Study(Base): # type: ignore created_at = Column(DateTime, index=True) updated_at = Column(DateTime, index=True) last_access = Column(DateTime) - path = Column(String) + path = Column(String()) folder = Column(String, nullable=True, index=True) parent_id = Column(String(36), ForeignKey("study.id", name="fk_study_study_id"), index=True) public_mode = Column(Enum(PublicMode), default=PublicMode.NONE) @@ -291,12 +291,15 @@ def to_json_summary(self) -> t.Any: @validates("folder") def validate_folder(self, key, folder) -> str: + """ + We want to store the path in posix format in the database, even on windows. + """ return normalize_path(folder) def normalize_path(path: str) -> str: """ - We want to store the path in posix format in the database, even on windows. + Turns any path including a windows path (with \ separator) to a posix path (with / separator). """ if not path: return path diff --git a/tests/storage/test_service.py b/tests/storage/test_service.py index f8b1770bd1..a6d36131f9 100644 --- a/tests/storage/test_service.py +++ b/tests/storage/test_service.py @@ -387,7 +387,7 @@ def test_windows_path_scan() -> None: repository.save.assert_called_with( RawStudy( id=ANY, - path="directory/b", + path=f"directory{os.sep}b", name="b", folder="directory/b", created_at=ANY,