From 1da729cd7d7347bea7fd994f4843e4e30519bfe1 Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:54:41 +0200 Subject: [PATCH] test --- .github/workflows/backend.yml | 68 +++++++++++++ .github/workflows/commitlint.yml | 9 +- .github/workflows/deploy.yml | 3 +- .github/workflows/frontend.yml | 92 +++++++++++++++++ .github/workflows/main.yml | 166 ------------------------------- .github/workflows/sonarcloud.yml | 19 ++++ .github/workflows/worker.yml | 1 + docs/CHANGELOG.md | 2 +- docs/index.md | 13 ++- requirements-dev.txt | 2 +- 10 files changed, 199 insertions(+), 176 deletions(-) create mode 100644 .github/workflows/backend.yml create mode 100644 .github/workflows/frontend.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000000..ee79ac62b3 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,68 @@ +name: backend + +pull_request: + paths: + - "antarest/**" + - "resources/**" + - "tests/**" + - "requirements*.txt" + +jobs: + python-lint: + runs-on: ubuntu-20.04 + steps: + - name: Checkout GitHub repo (+ download lfs dependencies) + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - uses: isort/isort-action@master + with: + sort-paths: antarest, tests + requirementsFiles: "requirements-dev.txt" + - name: Check with black + uses: psf/black@stable + with: + # Version of Black should match the versions set in `requirements-dev.txt` + version: "~=23.7.0" + options: --check --diff + - name: Check Typing (mypy) + #continue-on-error: true + run: | + mypy --install-types --non-interactive + + python-test: + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 9 + matrix: + os: [windows-latest, ubuntu-20.04] + steps: + - name: Checkout GitHub repo (+ download lfs dependencies) + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Test with pytest + run: | + pytest --cov antarest --cov-report xml + - name: Fix code coverage paths + if: matrix.os == 'ubuntu-20.04' + run: | + sed -i 's/\/home\/runner\/work\/AntaREST\/AntaREST/\/github\/workspace/g' coverage.xml + - name: Archive code coverage results + if: matrix.os == 'ubuntu-20.04' + uses: actions/upload-artifact@v4 + with: + name: python-code-coverage-report + path: coverage.xml diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 89b899c5a3..0a0a756d07 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -1,4 +1,5 @@ -name: Lint Commit Messages +name: commitlint + on: [pull_request] permissions: @@ -9,5 +10,7 @@ jobs: commitlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: wagoid/commitlint-github-action@v5 + - name: Checkout GitHub repo + uses: actions/checkout@v4 + - name: Lint Commit Messages + uses: wagoid/commitlint-github-action@v5 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e91a2a0b65..c662f2ff6b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ name: deploy + on: push: branches: - "master" - - "hotfix/**" jobs: binary: @@ -12,7 +12,6 @@ jobs: max-parallel: 3 matrix: os: [ windows-latest, ubuntu-20.04, ubuntu-22.04] - steps: - name: 🐙 Checkout GitHub repo (+ download lfs dependencies) uses: actions/checkout@v4 diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 0000000000..fe94f87132 --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,92 @@ +name: frontend + +on: + pull_request: + paths: + - "webapp/**" + +jobs: + 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: 18.16.1 + - 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: 18.16.1 + - 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: 18.16.1 + - 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: 18.16.1 + - 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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 4b1038ddcd..0000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,166 +0,0 @@ -name: main -on: - push: - branches: - - "**" - -jobs: - python-lint: - runs-on: ubuntu-20.04 - steps: - - name: Checkout github repo (+ download lfs dependencies) - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt - - uses: isort/isort-action@master - with: - sort-paths: antarest, tests - requirementsFiles: "requirements-dev.txt" - - name: Check with black - uses: psf/black@stable - with: - # Version of Black should match the versions set in `requirements-dev.txt` - version: "~=23.7.0" - options: --check --diff - - name: Check Typing (mypy) - #continue-on-error: true - run: | - mypy --install-types --non-interactive - - python-test: - runs-on: ${{ matrix.os }} - strategy: - max-parallel: 9 - matrix: - os: [windows-latest, ubuntu-20.04] - - steps: - - name: Checkout github repo (+ download lfs dependencies) - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt - - name: Test with pytest - run: | - pytest --cov antarest --cov-report xml - - name: Fix code coverage paths - if: matrix.os == 'ubuntu-20.04' - run: | - sed -i 's/\/home\/runner\/work\/AntaREST\/AntaREST/\/github\/workspace/g' coverage.xml - - name: Archive code coverage results - if: matrix.os == 'ubuntu-20.04' - uses: actions/upload-artifact@v4 - with: - 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: 18.16.1 - - 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: 18.16.1 - - 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: 18.16.1 - - 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: 18.16.1 - - 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@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000000..4652b5c0da --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,19 @@ +name: sonarcloud + +on: [pull_request] + +jobs: + 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@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/worker.yml b/.github/workflows/worker.yml index 4839670d62..01ba9d7f8a 100644 --- a/.github/workflows/worker.yml +++ b/.github/workflows/worker.yml @@ -1,4 +1,5 @@ name: worker + on: push: branches: diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e384f281d9..235d81cf78 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1211,7 +1211,7 @@ v2.13.0 (2023-03-09) * update version to 2.13.0 ([a44a896](https://github.com/AntaresSimulatorTeam/AntaREST/commit/a44a8964da226931b7a67b95765abc7baf031eb4)) * remove redundant call to `mypy` in GitHub actions. ([96e2b82](https://github.com/AntaresSimulatorTeam/AntaREST/commit/96e2b824eb348d1a3fe5bacf89de35e9cb7fc0fa)) -* upgrade Black version in `requirements-dev.txt` and `.github/workflows/main.yml`. ([464c7ff](https://github.com/AntaresSimulatorTeam/AntaREST/commit/464c7ff1ea877646815a3c70891e36b976b856d8)) +* upgrade Black version in `requirements-dev.txt` and `.github/workflows/backend.yml`. ([464c7ff](https://github.com/AntaresSimulatorTeam/AntaREST/commit/464c7ff1ea877646815a3c70891e36b976b856d8)) > IMPORTANT: The `antares-launcher` project (source files) is no longer needed, > because the `Antares-Launcher` Python library is now declared as a dependency diff --git a/docs/index.md b/docs/index.md index 4e1a2f818f..8e5d621978 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,4 +1,7 @@ -[![Status][ci_result]][ci_result_link] [![Quality Gate Status][coverage_result]][coverage_result_link] [![License][license_badge]][license_link] +[![Status][ci_backend_result]][ci_backend_result_link] +[![Status][ci_frontend_result]][ci_frontend_result_link] +[![Quality Gate Status][coverage_result]][coverage_result_link] +[![License][license_badge]][license_link] ![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54) ![TypeScript](https://img.shields.io/badge/TypeScript-00599c?style=for-the-badge&logo=TypeScript&logoColor=61DAFB) @@ -39,9 +42,13 @@ This integration brings: `Antares-Web` is currently under development. Feel free to submit any issue. -[ci_result]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/main.yml/badge.svg +[ci_backend_result]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/backend.yml/badge.svg -[ci_result_link]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/main.yml +[ci_backend_result_link]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/backend.yml + +[ci_frontend_result]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/frontend.yml/badge.svg + +[ci_frontend_result_link]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/frontend.yml [coverage_result]: https://sonarcloud.io/api/project_badges/measure?project=AntaresSimulatorTeam_api-iso-antares&metric=coverage diff --git a/requirements-dev.txt b/requirements-dev.txt index e7ff79c736..ef34693851 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -r requirements-test.txt -# Version of Black should match the versions set in `.github/workflows/main.yml` +# Version of Black should match the versions set in `.github/workflows/backend.yml` black~=23.7.0 isort~=5.12.0 mypy~=1.4.1