Appknox CLI Test Automation #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Appknox CLI Test Automation | |
| on: | |
| push: | |
| branches: [ main, master, develop ] | |
| pull_request: | |
| branches: [ main, master ] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Install Appknox CLI (Linux) | |
| run: | | |
| echo "Fetching latest Appknox CLI release..." | |
| latest=$(curl -s https://api.github.com/repos/appknox/appknox-go/releases/latest) | |
| # Extract the .deb asset URL | |
| url=$(echo "$latest" | grep browser_download_url | grep "linux-amd64.deb" | cut -d '"' -f 4) | |
| if [ -z "$url" ]; then | |
| echo "❌ Linux .deb package not found in latest release!" | |
| exit 1 | |
| fi | |
| echo "Downloading: $url" | |
| wget "$url" -O appknox.deb | |
| echo "Installing..." | |
| sudo dpkg -i appknox.deb || sudo apt-get install -f -y | |
| echo "Verifying..." | |
| appknox --version | |
| - name: Run TestSuite | |
| run: mvn clean test -Dtest=com.appknox.tests.TestSuite | |
| env: | |
| APPKNOX_API_HOST: ${{ secrets.APPKNOX_HOST }} | |
| APPKNOX_ACCESS_TOKEN: ${{ secrets.APPKNOX_TOKEN }} | |
| - name: Generate Allure Report | |
| if: always() | |
| run: mvn allure:report | |
| - name: Upload Allure Results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: allure-results | |
| path: target/allure-results | |
| retention-days: 30 | |
| - name: Upload Test Reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-reports | |
| path: | | |
| target/surefire-reports | |
| target/site/allure-maven-plugin | |
| retention-days: 30 | |
| - name: Test Summary | |
| if: always() | |
| run: | | |
| echo "## Test Execution Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| xml_files=$(ls target/surefire-reports/*.xml 2>/dev/null | wc -l) | |
| if [ "$xml_files" -gt 0 ]; then | |
| total=0 | |
| fail=0 | |
| err=0 | |
| for f in target/surefire-reports/*.xml; do | |
| tests=$(xmllint --xpath "string(/testsuite/@tests)" "$f") | |
| failures=$(xmllint --xpath "string(/testsuite/@failures)" "$f") | |
| errors=$(xmllint --xpath "string(/testsuite/@errors)" "$f") | |
| total=$((total + tests)) | |
| fail=$((fail + failures)) | |
| err=$((err + errors)) | |
| done | |
| pass=$((total - fail - err)) | |
| echo "**Total Tests:** $total" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ **Passed:** $pass" >> $GITHUB_STEP_SUMMARY | |
| echo "❌ **Failed:** $fail" >> $GITHUB_STEP_SUMMARY | |
| echo "💥 **Errors:** $err" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ No test reports found" >> $GITHUB_STEP_SUMMARY | |