From 6834f1879f7cd432894615d8fa3310a3a2985b01 Mon Sep 17 00:00:00 2001 From: andrei Date: Fri, 21 Mar 2025 15:54:12 +0100 Subject: [PATCH 1/2] refactor: remove broken workflows --- .github/workflows/build-and-lint-backend.yml | 127 ------------------ .github/workflows/build-and-lint-frontend.yml | 36 ----- .github/workflows/docker-publish.yml | 90 ------------- 3 files changed, 253 deletions(-) delete mode 100644 .github/workflows/build-and-lint-backend.yml delete mode 100644 .github/workflows/build-and-lint-frontend.yml delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/build-and-lint-backend.yml b/.github/workflows/build-and-lint-backend.yml deleted file mode 100644 index 20dd5381b..000000000 --- a/.github/workflows/build-and-lint-backend.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: CI Backend - -on: - # push: - # pull_request: - # types: [synchronize, opened] - workflow_dispatch: - -jobs: - # Python ORCID worker job - test_orcid_worker: - name: Lint, Test and Build ORCID Worker - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - - name: Install Python dependencies - run: | - cd server/workers/orcid - pip install --upgrade pip - # Install main dependencies - pip install --no-cache-dir -r requirements.txt - # Install dev dependencies (linters, tests, formatters) - pip install --no-cache-dir -r requirements-e.txt - # Install dev dependencies (linters, tests, formatters) - pip install --no-cache-dir -r requirements-dev.txt - - # - name: Lint and format check - # run: | - # cd server/workers/orcid - # # Check formatting with black: - # black --check src - # # Check import sorting: - # isort --check-only src - # # Linting with flake8 - # flake8 src - - # - name: Static type checking (mypy) - # run: | - # cd server/workers/orcid - # mypy src - - - name: Run tests with coverage - run: | - cd server/workers/orcid - pytest --maxfail=1 --disable-warnings -v --cov=src --cov-report=xml test - - - name: Build Docker image for ORCID worker - # Build the image with the same context as in your docker-compose - run: | - docker build -f server/workers/orcid/Dockerfile -t your-org/orcid-worker:latest server - - - name: Build Docker image for ORCID worker - # Build the image with the same context as in your docker-compose - run: | - docker build -f server/workers/orcid/Dockerfile -t your-org/orcid-worker:latest server - - # - name: Build Docker image for DATAPROCESSING worker - # # Build the image with the same context as in your docker-compose - # run: | - # docker build -f server/workers/dataprocessing/Dockerfile -t your-org/dataprocessing-worker:latest server - - # - name: Build Docker image for METRICS worker - # # Build the image with the same context as in your docker-compose - # run: | - # docker build -f server/workers/metrics/Dockerfile -t your-org/metrics-worker:latest server - - # - name: Build Docker image for OPENAIRE worker - # # Build the image with the same context as in your docker-compose - # run: | - # docker build -f server/workers/openaire/Dockerfile -t your-org/openaire-worker:latest server - - # - name: Build Docker image for PUBMED worker - # # Build the image with the same context as in your docker-compose - # run: | - # docker build -f server/workers/pubmed/Dockerfile -t your-org/pubmed-worker:latest server - - # - name: Build Docker image for PERSISTENCE worker - # # Build the image with the same context as in your docker-compose - # run: | - # docker build -f server/workers/persistence/Dockerfile -t your-org/persistence-worker:latest server - - ci_api_worker: - name: Lint, Test and Build API Worker - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Build Docker image for API worker - # Build the image with the same context as in your docker-compose - run: | - docker build -f server/workers/api/Dockerfile -t your-org/api-worker:latest server - - ci_base_worker: - name: Lint, Test and Build BASE Worker - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Build Docker image for BASE worker - # Build the image with the same context as in your docker-compose - run: | - docker build -f server/workers/base/Dockerfile -t your-org/base-worker:latest server - - # ci_base_worker: - # name: Lint, Test and Build BASE Worker - # runs-on: ubuntu-latest - # steps: - # - name: Build Docker image for BASE worker - # # Build the image with the same context as in your docker-compose - # run: | - # docker build -f server/workers/base/Dockerfile -t your-org/base-worker:latest server - - # If you need to push the image to a registry, you can add authorization and push steps - # - name: Log in to registry - # run: echo ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | docker login -u ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin your-registry.com - # - # - name: Push Docker image - # run: docker push your-org/orcid-worker:latest diff --git a/.github/workflows/build-and-lint-frontend.yml b/.github/workflows/build-and-lint-frontend.yml deleted file mode 100644 index c652203fa..000000000 --- a/.github/workflows/build-and-lint-frontend.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: CI Frontend - -on: - workflow_dispatch: - # ! TODO - # push: - # pull_request: - # types: - # - synchronize - # - opened - -jobs: - build: - name: Build and lint frontend - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js 20.x - uses: actions/setup-node@v4 - with: - node-version: 20.x - - - name: Install dependencies - run: npm install - - - name: Copy config file - run: cp config.example.js config.js - - - name: Lint code - run: npm run lint - - - name: Build project - run: npx webpack \ No newline at end of file diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 786432bec..000000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Build and Publish Docker Images to GHCR - -# Trigger the workflow only on pushes to the main branch -on: - push: - workflow_dispatch: - pull_request: - types: - - synchronize - - opened - # TODO: replace it later - # push: - # branches: - # - main - -permissions: - contents: read - packages: write - -jobs: - build-and-push-images: - name: Build and Push Docker Images - runs-on: ubuntu-latest - - steps: - # Step 1: Checkout the repository - - name: Checkout repository - uses: actions/checkout@v4 - - # Step 2: Set up Docker Buildx - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - # Step 3: Log in to GitHub Container Registry - - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - # GITHUB_TOKEN has read and write permissions by default in the context of GitHub Actions - password: ${{ secrets.GITHUB_TOKEN }} - - # Step 4: Build and push Docker images - - name: Build and Push ORCID Worker Image - uses: docker/build-push-action@v4 - with: - context: server - file: server/workers/orcid/Dockerfile - push: true - tags: ghcr.io/${{ github.repository_owner }}/orcid-worker:latest - - - name: Build and Push API Worker Image - uses: docker/build-push-action@v4 - with: - context: server - file: server/workers/api/Dockerfile - push: true - tags: ghcr.io/${{ github.repository_owner }}/api-worker:latest - - - name: Build and Push BASE Worker Image - uses: docker/build-push-action@v4 - with: - context: server - file: server/workers/base/Dockerfile - push: true - tags: ghcr.io/${{ github.repository_owner }}/base-worker:latest - - # Uncomment and add similar steps for other workers - # - name: Build and Push DATAPROCESSING Worker Image - # uses: docker/build-push-action@v4 - # with: - # context: . - # file: server/workers/dataprocessing/Dockerfile - # push: true - # tags: ghcr.io/${{ github.repository_owner }}/dataprocessing-worker:latest - - # - name: Build and Push METRICS Worker Image - # uses: docker/build-push-action@v4 - # with: - # context: . - # file: server/workers/metrics/Dockerfile - # push: true - # tags: ghcr.io/${{ github.repository_owner }}/metrics-worker:latest - - # Add more build steps as needed for other workers - - # Optional: Add a final step to verify or notify - - name: Verify Docker Images - run: | - echo "Docker images have been successfully built and pushed to GHCR." \ No newline at end of file From 3d937d249d4194c4c9c00fb0cacb7aecb432e265 Mon Sep 17 00:00:00 2001 From: andrei Date: Fri, 21 Mar 2025 16:05:50 +0100 Subject: [PATCH 2/2] feat: new GitHub Actions pipelines --- .github/workflows/backend.yml | 34 ++++ .github/workflows/frontend.yml | 54 +++++++ .../__snapshots__/list-base.test.jsx.snap | 152 +++++++++++++----- .../__snapshots__/listfilter.test.jsx.snap | 76 ++++++--- 4 files changed, 262 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/backend.yml create mode 100644 .github/workflows/frontend.yml diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 000000000..8025c561f --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,34 @@ +name: Backend CI + +on: + push: + branches: + - "**" + +jobs: + persistence-unit-tests: + name: Unit tests for persistence functions + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Cache pip dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Give execution permissions to script + run: chmod +x tests_runners/persistence/locally.sh + + - name: Run tests + run: tests_runners/persistence/locally.sh diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 000000000..f593c3147 --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,54 @@ +name: Frontend CI + +on: + push: + branches: + - "**" + +jobs: + test: + name: Unit and snapshot tests + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Copy config file + run: cp config.example.js config.js + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm run test + + build: + name: Build the project like on production deployment + needs: test + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Copy the config file for the vis + run: cp config.example.js config.js + + - name: Setup Node.JS + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + + - name: Install all project dependencies + run: npm ci + + - name: Build the project (prod) + run: npx webpack diff --git a/vis/test/snapshot/__snapshots__/list-base.test.jsx.snap b/vis/test/snapshot/__snapshots__/list-base.test.jsx.snap index 33d2ffa43..b89738ab3 100644 --- a/vis/test/snapshot/__snapshots__/list-base.test.jsx.snap +++ b/vis/test/snapshot/__snapshots__/list-base.test.jsx.snap @@ -111,20 +111,40 @@ exports[`List entries component snapshot (BASE) > matches a snapshot (zoomed-in, role="button" type="button" > - show: - Any - - + > + + show: + + + Any + + +
    matches a snapshot (zoomed-in, role="button" type="button" > - sort by: - Relevance - - + > + + sort by: + + + Relevance + + +
      matches a snapshot (zoomed-out role="button" type="button" > - show: - Any - - + > + + show: + + + Any + + +
        matches a snapshot (zoomed-out role="button" type="button" > - sort by: - Relevance - - + > + + sort by: + + + Relevance + + +
          matches a snapshot 1`] = ` role="button" type="button" > - Filter by: - All - - + > + + Filter by: + + + All + + +
            matches a snapshot 1`] = ` role="button" type="button" > - Sort by: - Relevance - - + > + + Sort by: + + + Relevance + + +