From cc2639a6c8d2b00d5f95d708225a8e9af0108e2a Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Thu, 11 Apr 2024 12:40:46 +0200 Subject: [PATCH 1/6] Try run test after profile loaded --- .github/workflows/dev-ci.yml | 59 ++++++++++++++++++++++++++++++++++++ bin/analyze_entrypoints.py | 3 ++ 2 files changed, 62 insertions(+) diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml index 548ae51b..43a0fa49 100644 --- a/.github/workflows/dev-ci.yml +++ b/.github/workflows/dev-ci.yml @@ -11,6 +11,15 @@ concurrency: cancel-in-progress: true jobs: + get-pr: + # https://dev.to/suzukishunsuke/secure-github-actions-by-pullrequesttarget-641 + outputs: + merge_commit_sha: ${{steps.pr.outputs.merge_commit_sha}} + runs-on: ubuntu-latest + steps: + - uses: suzuki-shunsuke/get-pr-action@v0.1.0 + id: pr + test-utils: runs-on: ubuntu-latest steps: @@ -51,3 +60,53 @@ jobs: npm install npm run build working-directory: ./aiida-registry-app + + preview: + # This job is triggered by from PR from the aiida-registry repo, the developer of aiida-registry need to see the preview page of the PR + needs: [test-webpage-build, get-pr] + if: github.repository == 'aiidateam/aiida-registry' + runs-on: ubuntu-latest + strategy: + fail-fast: false + timeout-minutes: 180 + env: + COMMIT_AUTHOR: Deploy Action + COMMIT_AUTHOR_EMAIL: action@github.com + VITE_PR_PREVIEW_PATH: "/aiida-registry/pr-preview/pr-${{ github.event.number }}/" + + steps: + - name: Checkout Repo ⚡️ + uses: actions/checkout@v4 + with: + ref: ${{needs.get-pr.outputs.merge_commit_sha}} + - name: Create dev environment + uses: ./.github/actions/create-dev-env + + - name: Generate metadata + uses: ./.github/actions/generate-metadata + with: + gh_token: ${{ secrets.GITHUB_TOKEN }} + cache: false + + - uses: actions/setup-node@v3 + with: + node-version: '18.x' + - name: Install npm dependencies and build + run: | + echo $VITE_PR_PREVIEW_PATH + npm install + npm run build + working-directory: ./aiida-registry-app + + - name: Add plugins file to the build folder + run: cp plugins_metadata.json aiida-registry-app/dist/ + + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./aiida-registry-app/dist + preview-branch: gh-pages + umbrella-dir: pr-preview + action: auto + custom-url: + token: ${{ secrets.BOT_COMMENT_TOKEN }} # use aiida-bot token to deploy the preview diff --git a/bin/analyze_entrypoints.py b/bin/analyze_entrypoints.py index 0ce76097..6a261147 100644 --- a/bin/analyze_entrypoints.py +++ b/bin/analyze_entrypoints.py @@ -15,6 +15,9 @@ from typing import Dict, List import click +import aiida + +aiida.load_profile() ENTRY_POINT_GROUPS = [ "aiida.calculations", From 43f11f3f98e16f365e41a943cf3869beed5980fe Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Thu, 11 Apr 2024 12:48:06 +0200 Subject: [PATCH 2/6] Add wait for the profile to be ready for test --- aiida_registry/test_install.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/aiida_registry/test_install.py b/aiida_registry/test_install.py index 1001c3da..84ae6f82 100644 --- a/aiida_registry/test_install.py +++ b/aiida_registry/test_install.py @@ -8,6 +8,7 @@ import json import os import sys +import time from dataclasses import asdict, dataclass from aiida_registry.utils import add_registry_checks @@ -148,6 +149,24 @@ def test_install_one_docker(container_image, plugin): ) is_package_importable = True + # While loop to wait for the daemon to be ready timeont 120s + # This is a workaround for the daemon not being ready for the entrypoint analysis + # which require the profile to be loaded + print(" - Waiting for the daemon to be ready") + daemon_ready = False + timeout = 120 # 120s + end_time = time.time() + timeout + while not daemon_ready: + verdi_status = container.exec_run( + "verdi status", + user=user, + ).output.decode("utf8") + if "✔" in verdi_status: + daemon_ready = True + elif time.time() > end_time: + print(" >> ERROR: Daemon is not ready after 120s") + break + print( " - Extracting entry point metadata for {}".format(plugin["package_name"]) ) From c7452b5fde6cb5beae13f942c06bed5edc0e1de4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:49:06 +0000 Subject: [PATCH 3/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- aiida_registry/test_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiida_registry/test_install.py b/aiida_registry/test_install.py index 84ae6f82..1e460465 100644 --- a/aiida_registry/test_install.py +++ b/aiida_registry/test_install.py @@ -154,7 +154,7 @@ def test_install_one_docker(container_image, plugin): # which require the profile to be loaded print(" - Waiting for the daemon to be ready") daemon_ready = False - timeout = 120 # 120s + timeout = 120 # 120s end_time = time.time() + timeout while not daemon_ready: verdi_status = container.exec_run( From 0c5315fa547d36b63a843b2c4082876d69cbd0fd Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Thu, 11 Apr 2024 21:13:56 +0200 Subject: [PATCH 4/6] Use temp profile --- aiida_registry/test_install.py | 34 +++++++++++++++++----------------- bin/analyze_entrypoints.py | 7 +++++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/aiida_registry/test_install.py b/aiida_registry/test_install.py index 1e460465..b809a1b2 100644 --- a/aiida_registry/test_install.py +++ b/aiida_registry/test_install.py @@ -149,23 +149,23 @@ def test_install_one_docker(container_image, plugin): ) is_package_importable = True - # While loop to wait for the daemon to be ready timeont 120s - # This is a workaround for the daemon not being ready for the entrypoint analysis - # which require the profile to be loaded - print(" - Waiting for the daemon to be ready") - daemon_ready = False - timeout = 120 # 120s - end_time = time.time() + timeout - while not daemon_ready: - verdi_status = container.exec_run( - "verdi status", - user=user, - ).output.decode("utf8") - if "✔" in verdi_status: - daemon_ready = True - elif time.time() > end_time: - print(" >> ERROR: Daemon is not ready after 120s") - break + ## While loop to wait for the daemon to be ready timeont 120s + ## This is a workaround for the daemon not being ready for the entrypoint analysis + ## which require the profile to be loaded + #print(" - Waiting for the daemon to be ready") + #daemon_ready = False + #timeout = 120 # 120s + #end_time = time.time() + timeout + #while not daemon_ready: + # verdi_status = container.exec_run( + # "verdi status", + # user=user, + # ).output.decode("utf8") + # if "✔" in verdi_status: + # daemon_ready = True + # elif time.time() > end_time: + # print(" >> ERROR: Daemon is not ready after 120s") + # break print( " - Extracting entry point metadata for {}".format(plugin["package_name"]) diff --git a/bin/analyze_entrypoints.py b/bin/analyze_entrypoints.py index 6a261147..0dba8397 100644 --- a/bin/analyze_entrypoints.py +++ b/bin/analyze_entrypoints.py @@ -15,9 +15,12 @@ from typing import Dict, List import click -import aiida +from aiida import load_profile +from aiida.storage.sqlite_temp import SqliteTempBackend -aiida.load_profile() +# Load AiiDA profile +temp_profile = SqliteTempBackend.create_profile('temp-profile') +load_profile(temp_profile, allow_switch=True) ENTRY_POINT_GROUPS = [ "aiida.calculations", From 29d1ee3f074cf5fed8b2a091ccbe6109d82b1fe2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:14:46 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- aiida_registry/test_install.py | 11 +++++------ bin/analyze_entrypoints.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/aiida_registry/test_install.py b/aiida_registry/test_install.py index b809a1b2..2047d51f 100644 --- a/aiida_registry/test_install.py +++ b/aiida_registry/test_install.py @@ -8,7 +8,6 @@ import json import os import sys -import time from dataclasses import asdict, dataclass from aiida_registry.utils import add_registry_checks @@ -152,11 +151,11 @@ def test_install_one_docker(container_image, plugin): ## While loop to wait for the daemon to be ready timeont 120s ## This is a workaround for the daemon not being ready for the entrypoint analysis ## which require the profile to be loaded - #print(" - Waiting for the daemon to be ready") - #daemon_ready = False - #timeout = 120 # 120s - #end_time = time.time() + timeout - #while not daemon_ready: + # print(" - Waiting for the daemon to be ready") + # daemon_ready = False + # timeout = 120 # 120s + # end_time = time.time() + timeout + # while not daemon_ready: # verdi_status = container.exec_run( # "verdi status", # user=user, diff --git a/bin/analyze_entrypoints.py b/bin/analyze_entrypoints.py index 0dba8397..f49f88ab 100644 --- a/bin/analyze_entrypoints.py +++ b/bin/analyze_entrypoints.py @@ -19,7 +19,7 @@ from aiida.storage.sqlite_temp import SqliteTempBackend # Load AiiDA profile -temp_profile = SqliteTempBackend.create_profile('temp-profile') +temp_profile = SqliteTempBackend.create_profile("temp-profile") load_profile(temp_profile, allow_switch=True) ENTRY_POINT_GROUPS = [ From bf15f559af92872a4db73f0441d65b2f358aa44a Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Thu, 11 Apr 2024 22:21:45 +0200 Subject: [PATCH 6/6] Update aiida_registry/test_install.py --- aiida_registry/test_install.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/aiida_registry/test_install.py b/aiida_registry/test_install.py index 2047d51f..1001c3da 100644 --- a/aiida_registry/test_install.py +++ b/aiida_registry/test_install.py @@ -148,24 +148,6 @@ def test_install_one_docker(container_image, plugin): ) is_package_importable = True - ## While loop to wait for the daemon to be ready timeont 120s - ## This is a workaround for the daemon not being ready for the entrypoint analysis - ## which require the profile to be loaded - # print(" - Waiting for the daemon to be ready") - # daemon_ready = False - # timeout = 120 # 120s - # end_time = time.time() + timeout - # while not daemon_ready: - # verdi_status = container.exec_run( - # "verdi status", - # user=user, - # ).output.decode("utf8") - # if "✔" in verdi_status: - # daemon_ready = True - # elif time.time() > end_time: - # print(" >> ERROR: Daemon is not ready after 120s") - # break - print( " - Extracting entry point metadata for {}".format(plugin["package_name"]) )