From f6cae67fdf13a74e4e1f3af8309e9280cb25b706 Mon Sep 17 00:00:00 2001 From: Artem Rys Date: Fri, 3 Jan 2025 16:00:41 +0100 Subject: [PATCH] ci: new add-on passes AppInspect (#1501) **Issue number:** N/A ### PR Type **What kind of change does this PR introduce?** * [ ] Feature * [ ] Bug Fix * [ ] Refactoring (no functional or API changes) * [ ] Documentation Update * [x] Maintenance (dependency updates, CI, etc.) ## Summary ### Changes Introduce a new test to verify that the new add-on (init -> build -> package) passes Splunk's AppInspect checks. It contains one hack ``` echo "# Binary File Declaration\n\nIgnoring lib/charset_normalizer/md.cpython-37m-x86_64-linux-gnu.so" > demo_addon_for_splunk/package/README.txt ``` to make sure we actually pass AppInspect checks. We will need to follow up on it with the team and see how this can be solved long-term. ### User experience N/A ## Checklist If an item doesn't apply to your changes, leave it unchecked. * [x] I have performed a self-review of this change according to the [development guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines) * [ ] Tests have been added/modified to cover the changes [(testing doc)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test) * [ ] Changes are documented * [x] PR title and description follows the [contributing principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests) --- .github/workflows/build-test-release.yml | 114 +++++++++++++++-------- .gitignore | 1 + 2 files changed, 76 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-test-release.yml b/.github/workflows/build-test-release.yml index 3af96a677..53854dd76 100644 --- a/.github/workflows/build-test-release.yml +++ b/.github/workflows/build-test-release.yml @@ -355,6 +355,81 @@ jobs: name: appinspect-api-html-report-${{ matrix.tags }} path: AppInspect_response.html + init-build-run-appinspect-cli: + runs-on: ubuntu-22.04 + needs: + - build + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.7" + - uses: actions/download-artifact@v4 + with: + name: UCC-UI-build + path: built-ui/ + - run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1 + - run: | + cp -R built-ui/. splunk_add_on_ucc_framework/package/appserver/static/js/ + poetry install --only main + - run: | + poetry run ucc-gen init \ + --addon-name "demo_addon_for_splunk" \ + --addon-display-name "Demo Add-on for Splunk" \ + --addon-input-name demo_input \ + --add-license "Apache License 2.0" \ + --include-author Splunk + - run: | + echo "# Binary File Declaration\n\nIgnoring lib/charset_normalizer/md.cpython-37m-x86_64-linux-gnu.so" > demo_addon_for_splunk/package/README.txt + - run: | + poetry run ucc-gen build --source demo_addon_for_splunk/package --ta-version 0.0.1 + - run: | + mkdir packaged + poetry run ucc-gen package --path output/demo_addon_for_splunk -o packaged + - run: | + python3 -m pip install splunk-appinspect + - run: | + splunk-appinspect inspect packaged/demo_addon_for_splunk-0.0.1.tar.gz --mode test --included-tags cloud + + build-test-addon-openapi-client: + name: build-test-addon-openapi-client Splunk ${{ matrix.splunk.version }} + runs-on: ubuntu-22.04 + needs: + - meta + - build-test-addon + - build + - test-unit + - test-smoke + strategy: + matrix: + splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + - uses: actions/download-artifact@v4 + with: + name: UCC-UI-build + path: built-ui/ + - run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1 + - run: | + cp -R built-ui/. splunk_add_on_ucc_framework/package/appserver/static/js/ + poetry install --only main + - run: poetry run ucc-gen build --source tests/testdata/test_addons/package_global_config_everything/package -o out_${{ matrix.splunk.version }} + - run: | + cp out_${{ matrix.splunk.version }}/Splunk_TA_UCCExample/appserver/static/openapi.json ./oa_${{ matrix.splunk.version }}.json + docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/oa_${{ matrix.splunk.version }}.json -g python -o /local/restapi_client_${{ matrix.splunk.version }} + - run: | + sudo chmod -R 777 ./restapi_client_${{ matrix.splunk.version }} + python3 -m pip install ./restapi_client_${{ matrix.splunk.version }} + - run: mv out_${{ matrix.splunk.version }} output + - run: | + ./scripts/run_splunk.sh ${{ matrix.splunk.version }} + until curl -Lsk "https://localhost:8088/services/collector/health" &>/dev/null ; do echo -n "Waiting for HEC-" && sleep 5 ; done + timeout-minutes: 5 + - run: python3 tests/testdata/expected_addons/expected_output_global_config_everything/client-test.py + all-checks: if: ${{ !cancelled() }} needs: @@ -436,42 +511,3 @@ jobs: run: | poetry build poetry publish -n -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_TOKEN }} - - build-test-addon-openapi-client: - name: build-test-addon-openapi-client Splunk ${{ matrix.splunk.version }} - runs-on: ubuntu-22.04 - needs: - - meta - - build-test-addon - - build - - test-unit - - test-smoke - strategy: - matrix: - splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - uses: actions/download-artifact@v4 - with: - name: UCC-UI-build - path: built-ui/ - - run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1 - - run: | - cp -R built-ui/. splunk_add_on_ucc_framework/package/appserver/static/js/ - poetry install --only main - - run: poetry run ucc-gen build --source tests/testdata/test_addons/package_global_config_everything/package -o out_${{ matrix.splunk.version }} - - run: | - cp out_${{ matrix.splunk.version }}/Splunk_TA_UCCExample/appserver/static/openapi.json ./oa_${{ matrix.splunk.version }}.json - docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/oa_${{ matrix.splunk.version }}.json -g python -o /local/restapi_client_${{ matrix.splunk.version }} - - run: | - sudo chmod -R 777 ./restapi_client_${{ matrix.splunk.version }} - python3 -m pip install ./restapi_client_${{ matrix.splunk.version }} - - run: mv out_${{ matrix.splunk.version }} output - - run: | - ./scripts/run_splunk.sh ${{ matrix.splunk.version }} - until curl -Lsk "https://localhost:8088/services/collector/health" &>/dev/null ; do echo -n "Waiting for HEC-" && sleep 5 ; done - timeout-minutes: 5 - - run: python3 tests/testdata/expected_addons/expected_output_global_config_everything/client-test.py diff --git a/.gitignore b/.gitignore index 1f5efe983..22fa40a7c 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ demo_addon_for_splunk_already_exists/ demo_addon_for_splunk_license/ addon_name init_addon_for_ucc_package/ +demo_addon_for_splunk/ # UI build # ignore everything except redirect_page.js