diff --git a/.github/workflows/build.yaml b/.github/workflows/build-nms.yaml similarity index 96% rename from .github/workflows/build.yaml rename to .github/workflows/build-nms.yaml index 857a5b15..11e7856e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build-nms.yaml @@ -4,7 +4,7 @@ on: workflow_call: jobs: - build: + build-nms: runs-on: ubuntu-22.04 steps: - name: Checkout repository diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml deleted file mode 100644 index 729bdecb..00000000 --- a/.github/workflows/integration_tests.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: Integration tests - -on: - workflow_call: - -jobs: - integration-tests: - runs-on: ubuntu-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - - uses: canonical/craft-actions/rockcraft-pack@main - id: rockcraft - with: - rockcraft-channel: edge - - - name: Import the image to Docker registry - run: | - sudo rockcraft.skopeo --insecure-policy copy oci-archive:${{ steps.rockcraft.outputs.rock }} docker-daemon:sdcore-nms:0.1 - - - name: Run the image - run: | - docker run -d -p 3000:3000 --entrypoint /bin/bash sdcore-nms:0.1 -c 'cd /app && npm run start' - - - name: Check if the NMS is successfully running - id: test_image - run: | - sleep 10 # Wait for the container to be ready - curl localhost:3000/network-configuration | grep -i '5G NMS' - - - uses: actions/upload-artifact@v4 - if: steps.test_image.outcome == 'success' - with: - name: rock - path: ${{ steps.rockcraft.outputs.rock }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b386203f..351e8bc6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -10,18 +10,22 @@ on: - cron: "0 0 * * 0" jobs: - lint-report: - uses: ./.github/workflows/lint-report.yaml + nms-lint-report: + uses: ./.github/workflows/nms-lint-report.yaml - build: - needs: lint-report - uses: ./.github/workflows/build.yaml + build-nms: + needs: nms-lint-report + uses: ./.github/workflows/build-nms.yaml - integration-tests: - needs: build - uses: ./.github/workflows/integration_tests.yaml + build-rock: + needs: build-nms + uses: canonical/sdcore-github-workflows/.github/workflows/build-rock.yaml@v1.0.0 - publish: + scan-rock: + needs: build-rock + uses: canonical/sdcore-github-workflows/.github/workflows/scan-rock.yaml@v1.0.0 + + publish-rock: if: github.ref_name == 'main' - needs: integration-tests - uses: ./.github/workflows/publish.yaml + needs: scan-rock + uses: canonical/sdcore-github-workflows/.github/workflows/publish-rock.yaml@v1.0.0 diff --git a/.github/workflows/lint-report.yaml b/.github/workflows/nms-lint-report.yaml similarity index 95% rename from .github/workflows/lint-report.yaml rename to .github/workflows/nms-lint-report.yaml index 6dc37f2f..f21e1b1b 100644 --- a/.github/workflows/lint-report.yaml +++ b/.github/workflows/nms-lint-report.yaml @@ -4,7 +4,7 @@ on: workflow_call: jobs: - lint-report: + nms-lint-report: runs-on: ubuntu-22.04 steps: - name: Checkout repository diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 1e258a8d..00000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: Publish - -on: - workflow_call: - -jobs: - publish: - runs-on: ubuntu-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - - name: Log in to the Container registry - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Install yq - run: | - sudo snap install yq - - uses: actions/download-artifact@v4 - with: - name: rock - - - name: Import - run: | - sudo snap install rockcraft --edge --classic - image_name="$(yq '.name' rockcraft.yaml)" - echo "image_name=${image_name}" >> $GITHUB_ENV - version="$(yq '.version' rockcraft.yaml)" - echo "version=${version}" >> $GITHUB_ENV - rock_file=$(ls *.rock | tail -n 1) - sudo rockcraft.skopeo \ - --insecure-policy \ - copy \ - oci-archive:"${rock_file}" \ - docker-daemon:"ghcr.io/canonical/${image_name}:${version}" - - - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master - with: - image-ref: "ghcr.io/canonical/${{env.image_name}}:${{env.version}}" - format: "sarif" - output: "trivy-results.sarif" - - - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: "trivy-results.sarif" - - - name: Push to github package - run: | - docker push ghcr.io/canonical/${{env.image_name}}:${{env.version}} diff --git a/rockcraft.yaml b/rockcraft.yaml index 390d8e3e..0dae7f64 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -8,17 +8,7 @@ license: Apache-2.0 platforms: amd64: -services: - nms: - command: npm run start - override: replace - startup: enabled - working-dir: app - environment: - WEBUI_ENDPOINT: http://10.1.182.9:5000 - parts: - nms: plugin: nil source: . @@ -27,14 +17,36 @@ parts: build-snaps: - node/20/stable override-build: | - mkdir -p ${CRAFT_PART_INSTALL}/app - + craftctl default npm ci npm run build - cp -r .next ${CRAFT_PART_INSTALL}/app/ - cp -r node_modules ${CRAFT_PART_INSTALL}/app/ - cp package.json ${CRAFT_PART_INSTALL}/app/ + mkdir -p ${CRAFT_PART_INSTALL}/app + cp -r out/* ${CRAFT_PART_INSTALL}/app/ + stage: + - app + prime: + - -app + webui: + after: + - nms + plugin: go + source: https://github.com/omec-project/webconsole.git + source-type: git + source-tag: v1.4.2 + build-snaps: + - go/1.21/stable + go-buildtags: + - ui + stage-packages: + - libc6_libs + - base-files_lib + organize: + bin/cmd: bin/webui + override-build: | + rm -rf ${CRAFT_PART_BUILD}/ui/frontend_files/* + cp -r ${CRAFT_STAGE}/app/* ${CRAFT_PART_BUILD}/ui/frontend_files + craftctl default version: plugin: nil override-build: |