diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml new file mode 100644 index 00000000..0de9242a --- /dev/null +++ b/.github/workflows/build_deploy.yml @@ -0,0 +1,210 @@ +name: Build & Deploy (manually) + +on: + workflow_dispatch: + inputs: + + branch: + description: 'Branch to (re)deploy from' + required: true + default: 'development' + type: choice + options: + - main + - development + - release/0.6.6 + - release/0.6.7 + - release/0.6.8 + - release/0.6.9 + - release/0.6.10 + - release/0.6.11 + - release/0.6.12 + - release/0.7.0 + - release/0.7.1 + - release/0.7.2 + - release/0.7.3 + - release/0.7.4 + - release/0.7.5 + - release/0.7.6 + - release/0.7.7 + - release/0.7.7.1 + - release/0.7.8 + - release/0.7.8.1 + - release/0.7.9 + - release/0.8.0 + - release/0.8.1 + - release/0.8.2 + - release/0.8.3 + + environment: + description: 'Environment to (re)deploy to' + type: environment + default: 'development' + required: true + +jobs: + + build_frontend: + + name: build frontend + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install npm packages + run: | + cd frontend + npm install + + - name: Build & bundle + run: | + cd frontend + unset CI # ignore React warnings + npm run build + + build_backend: + + name: build backend + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + + - name: Fetch submodules + run: | + cd backend + cd apps + git submodule update --init --recursive + git submodule update --remote + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Create venv + run: | + cd backend + python3.11 -m venv venv + + - name: Install packages + run: | + cd backend + source venv/bin/activate + pip install --upgrade pip + pip install -r requirements.txt + + - name: Install ifcopenshell package (temp) + run: | + cd backend + source venv/bin/activate + # use version of ifcopenshell with desired schema parsing + # TODO: revert to pyPI when schema parsing is published in the future + wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.8.1-92b63a0-linux64.zip" + mkdir -p venv/lib/python3.11/site-packages + unzip -d venv/lib/python3.11/site-packages /tmp/ifcopenshell_python.zip + + - name: Check Django config + run: | + cd backend + source venv/bin/activate + python3 manage.py check + + - name: Run tests + run: | + cd backend + source venv/bin/activate + python3 manage.py test + + deploy: + + name: deploy to server (${{ inputs.environment }}) + needs: [build_frontend, build_backend] + runs-on: ubuntu-latest + environment: + name: ${{ inputs.environment }} + + steps: + - name: Configure SSH + run: | + mkdir -p ~/.ssh/ + echo "$SSH_KEY" > ~/.ssh/ssh_host.key + chmod 600 ~/.ssh/ssh_host.key + cat >>~/.ssh/config < .VERSION' + + - name: Build Docker images + run: | + ssh ssh_host 'cd ${{ vars.REPO_CLONE_PATH }} + sudo make rebuild' + + - name: Start Docker containers + run: | + ssh ssh_host 'cd ${{ vars.REPO_CLONE_PATH }} + sudo docker compose -f ${{ vars.DOCKER_COMPOSE_FILE }} --env-file ${{ vars.ENV_FILE }} up -d' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index be381f35..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: Testing (CI - DEV) - -concurrency: - group: development - cancel-in-progress: true - -on: - pull_request: - branches: - - development - paths-ignore: - - 'README.md' - workflow_dispatch: - -jobs: - - build_frontend: - - name: build frontend - runs-on: ubuntu-latest - environment: - name: development - - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install npm packages - run: | - cd frontend - npm install - - - name: Build & bundle - run: | - cd frontend - unset CI # ignore React warnings - npm run build - - build_backend: - - name: build backend - runs-on: ubuntu-latest - environment: - name: development - - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Fetch submodules - run: | - git clean -fdx -e ${{ vars.ENV_FILE }} -e 'redeploy.*.sh' -e 'docker/' - git submodule foreach --recursive 'git clean -fdx' - cd backend - cd apps - git submodule update --init --recursive - git submodule update --remote - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - - name: Create venv - run: | - cd backend - python3.11 -m venv venv - - - name: Install packages - run: | - cd backend - source venv/bin/activate - pip install --upgrade pip - find . -name 'requirements.txt' -exec pip install -r {} \; - - - name: Install ifcopenshell package (temp) - run: | - cd backend - source venv/bin/activate - # use version of ifcopenshell with desired schema parsing - # TODO: revert to pyPI when schema parsing is published in the future - wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.8.4-6924012-linux64.zip" - mkdir -p venv/lib/python3.11/site-packages - unzip -d venv/lib/python3.11/site-packages /tmp/ifcopenshell_python.zip - - - name: Check Django config - run: | - cd backend - source venv/bin/activate - python3 manage.py check - - - name: Run tests - run: | - cd backend - source venv/bin/activate - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps/ifc_validation_models --settings apps.ifc_validation_models.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_header_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_header_syntax_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_syntax_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_schema_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 \ No newline at end of file diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml deleted file mode 100644 index 91b73b57..00000000 --- a/.github/workflows/ci_cd.yml +++ /dev/null @@ -1,173 +0,0 @@ -name: Build & Deploy (CI/CD - DEV) - -concurrency: - group: development - cancel-in-progress: true - -on: - push: - branches: - - development - paths-ignore: - - 'README.md' - - '.github/workflows/playwright.yml' - workflow_dispatch: - -jobs: - - build_frontend: - - name: build frontend - runs-on: ubuntu-latest - environment: - name: development - - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install npm packages - run: | - cd frontend - npm install - - - name: Build & bundle - run: | - cd frontend - unset CI # ignore React warnings - npm run build - - build_backend: - - name: build backend - runs-on: ubuntu-latest - environment: - name: development - - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Fetch submodules - run: | - git clean -fdx -e ${{ vars.ENV_FILE }} -e 'redeploy.*.sh' -e 'docker/' - git submodule foreach --recursive 'git clean -fdx' - cd backend - cd apps - git submodule update --init --recursive - git submodule update --remote - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - - name: Create venv - run: | - cd backend - python3.11 -m venv venv - - - name: Install packages - run: | - cd backend - source venv/bin/activate - pip install --upgrade pip - find . -name 'requirements.txt' -exec pip install -r {} \; - - - name: Install ifcopenshell package (temp) - run: | - cd backend - source venv/bin/activate - # use version of ifcopenshell with desired schema parsing - # TODO: revert to pyPI when schema parsing is published in the future - wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.8.4-6924012-linux64.zip" - mkdir -p venv/lib/python3.11/site-packages - unzip -d venv/lib/python3.11/site-packages /tmp/ifcopenshell_python.zip - - - name: Check Django config - run: | - cd backend - source venv/bin/activate - python3 manage.py check - - - name: Run tests - run: | - cd backend - source venv/bin/activate - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps/ifc_validation_models --settings apps.ifc_validation_models.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_header_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_header_syntax_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_syntax_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 - MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_schema_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3 - - deploy: - - name: deploy to server - needs: [build_frontend, build_backend] - if: github.event_name == 'push' - runs-on: ubuntu-latest - environment: - name: development - - steps: - - name: Set up SSH key - run: | - mkdir -p ~/.ssh - echo "${{ secrets.SSH_PRIV_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan -p 22 ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts - - - name: Install sshpass - run: sudo apt-get install sshpass - - - name: Stop Docker containers - run: | - sshpass ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} bash <<'ENDSSH' - cd ${{ vars.REPO_CLONE_PATH }} - sudo make stop - ENDSSH - - - name: Fetch sources & submodules - run: | - sshpass ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} bash <<'ENDSSH' - cd ${{ vars.REPO_CLONE_PATH }} - git checkout -q ${{ vars.BRANCH_NAME }} && git pull - git clean -fdx -e ${{ vars.ENV_FILE }} -e 'redeploy.*.sh' -e 'docker/' - git submodule foreach --recursive 'git clean -fdx' - sudo make fetch-modules - cd ${{ vars.REPO_CLONE_PATH }}/backend/apps/ifc_validation/checks/ifc_gherkin_rules && git checkout -q ${{ vars.BRANCH_NAME }} && git pull - cd ./ifc_validation_models && git checkout -q ${{ vars.BRANCH_NAME }} && git pull - cd ${{ vars.REPO_CLONE_PATH }}/backend/apps/ifc_validation_models && git checkout -q ${{ vars.BRANCH_NAME }} && git pull - cd ${{ vars.REPO_CLONE_PATH }} - ./check-submodules.sh - ENDSSH - - - name: Set VERSION - run: | - sshpass ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} bash <<'ENDSSH' - cd ${{ vars.REPO_CLONE_PATH }} - COMMIT_HASH=$(git rev-parse --short HEAD) - VERSION="${{ vars.VERSION }}" - echo "Set VERSION to ${VERSION}" - echo "Commit hash ${COMMIT_HASH}" - echo "${VERSION}" > .VERSION - ENDSSH - - - name: Build Docker images - run: | - sshpass ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} bash <<'ENDSSH' - cd ${{ vars.REPO_CLONE_PATH }} - sudo make rebuild - ENDSSH - - - name: Start Docker containers - run: | - sshpass ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} bash <<'ENDSSH' - cd ${{ vars.REPO_CLONE_PATH }} - sudo docker compose -f ${{ vars.DOCKER_COMPOSE_FILE }} --env-file ${{ vars.ENV_FILE }} up -d - ENDSSH diff --git a/.github/workflows/dispatch.yml b/.github/workflows/dispatch.yml new file mode 100644 index 00000000..c7b9c243 --- /dev/null +++ b/.github/workflows/dispatch.yml @@ -0,0 +1,96 @@ +name: Sync Submodules (CI/CD) + +# Checks, aligns and updates all submodules for development and main branches. +# +# Changes are triggered via repository_dispatch events in the submodule repositories: +# +# - ifc-gherkin-rules +# - ifc-validation-data-model + +on: repository_dispatch + +jobs: + + on_dispatch: + name: On Dispatch + runs-on: ubuntu-latest + + steps: + - name: Log received event + run: ${{ tojson(github.event) }} + shell: cat {0} + + - name: Dispatch from ifc-gherkin-rules (development) + run: echo "ifc-gherkin-rules (development branch)" + if: ${{ github.event.client_payload.repo == 'ifc-gherkin-rules' && github.event.client_payload.branch == 'development' }} + + - name: Dispatch from ifc-validation-data-model (development) + run: echo "ifc-validation-data-model (development branch)" + if: ${{ github.event.client_payload.repo == 'ifc-validation-data-model' && github.event.client_payload.branch == 'development' }} + + - name: Dispatch from ifc-gherkin-rules (main) + run: echo "ifc-gherkin-rules (main branch)" + if: ${{ github.event.client_payload.repo == 'ifc-gherkin-rules' && github.event.client_payload.branch == 'main' }} + + - name: Dispatch from ifc-validation-data-model (main) + run: echo "ifc-validation-data-model (main branch)" + if: ${{ github.event.client_payload.repo == 'ifc-validation-data-model' && github.event.client_payload.branch == 'main' }} + + - name: Checkout sources & submodules + run: | + cd ${{ github.workspace }} + git clone ${{ github.event.repository.clone_url }} . + git fetch && git pull + git checkout -q ${{ github.event.client_payload.branch }} + git submodule update --init --recursive + git submodule update --remote + + - name: Fetch latest submodule - ifc_gherkin_rules + run: | + cd ${{ github.workspace }}/backend/apps/ifc_validation/checks/ifc_gherkin_rules + git checkout -q ${{ github.event.client_payload.branch }} + + - name: Fetch latest submodule - ifc-validation-models + run: | + cd ${{ github.workspace }}/backend/apps/ifc_validation_models + git checkout -q ${{ github.event.client_payload.branch }} + + - name: Show submodule status + run: | + cd ${{ github.workspace }} + git submodule foreach --recursive "git remote get-url origin && git rev-parse --abbrev-ref HEAD && git rev-parse --short HEAD && echo $''" + + - name: Show repo status + run: | + cd ${{ github.workspace }} + echo "Validate repository" + git remote get-url origin && git rev-parse --abbrev-ref HEAD && git rev-parse --short HEAD + + - name: Add changes + run: | + cd ${{ github.workspace }} + git add backend/apps/ifc_validation/checks/ifc_gherkin_rules + git add backend/apps/ifc_validation_models + + - name: Show git status (pre) + run: | + cd ${{ github.workspace }} + git status + + - name: Commit changes (if any) + run: | + cd ${{ github.workspace }} + if [ -n "$(git status --porcelain)" ]; then + git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }} + git config --local user.name 'github-actions[bot]' + git config --local user.email 'github-actions[bot]@users.noreply.github.com' + git commit -am "Update of submodules (bSI-Bot via GH action)" + git push origin ${{ github.event.client_payload.branch }} + else + echo 'No changes to commit' + fi + + - name: Show git status (post) + run: | + cd ${{ github.workspace }} + git status diff --git a/.gitmodules b/.gitmodules index 51a6a5b0..06d8d26c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,11 +1,11 @@ [submodule "backend/apps/ifc_validation/checks/ifc_gherkin_rules"] path = backend/apps/ifc_validation/checks/ifc_gherkin_rules url = https://github.com/buildingSMART/ifc-gherkin-rules - branch = development + branch = main [submodule "backend/apps/ifc_validation_models"] path = backend/apps/ifc_validation_models url = https://github.com/buildingSMART/ifc-validation-data-model - branch = development + branch = main [submodule "backend/apps/ifc_validation/checks/signatures/store"] path = backend/apps/ifc_validation/checks/signatures/store url = https://github.com/buildingsmart-certificates/validation-service-vendor-certificates diff --git a/backend/apps/ifc_validation/checks/ifc_gherkin_rules b/backend/apps/ifc_validation/checks/ifc_gherkin_rules index 058d77b0..7d5ddd0c 160000 --- a/backend/apps/ifc_validation/checks/ifc_gherkin_rules +++ b/backend/apps/ifc_validation/checks/ifc_gherkin_rules @@ -1 +1 @@ -Subproject commit 058d77b0eb44b0b71c461333393d7a1cb1e5c683 +Subproject commit 7d5ddd0c3f25de194e9c49d23555615e37f6c333 diff --git a/backend/apps/ifc_validation_models b/backend/apps/ifc_validation_models index eb0180fc..b74a9d22 160000 --- a/backend/apps/ifc_validation_models +++ b/backend/apps/ifc_validation_models @@ -1 +1 @@ -Subproject commit eb0180fc2a414e3a544c655ac7d0f289c3acf37b +Subproject commit b74a9d22e0f6d2e5240d76c0a8360c6678d3e102 diff --git a/frontend/src/SideMenu.js b/frontend/src/SideMenu.js index 1b5791d1..70505de2 100644 --- a/frontend/src/SideMenu.js +++ b/frontend/src/SideMenu.js @@ -21,26 +21,39 @@ const drawerWidth = 240; export default function SideMenu() { const context = useContext(PageContext); + + const menuItems = [{ + text: "Home", + href: context.sandboxId ? `/sandbox/${context.sandboxId}` : "/", + icon: , + displayText: "Home", + }, + { + text: "Dashboard", + href: context.sandboxId ? `/sandbox/dashboard/${context.sandboxId}` : "/dashboard", + icon: , + displayText: "Validation", + },]; + return ( - - + - {['Home', 'Dashboard'].map((text, index) => ( - - + {menuItems.map((item, index) => ( + + - {text === "Home" ? : } + {item.icon} - + ))}