|
| 1 | +name: benchmark |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "main" |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - "main" |
| 10 | + |
| 11 | +concurrency: benchmark |
| 12 | + |
| 13 | +jobs: |
| 14 | + |
| 15 | + bench: |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + |
| 18 | + permissions: |
| 19 | + # deployments permission to deploy GitHub pages website |
| 20 | + deployments: write |
| 21 | + # contents permission to update benchmark contents in gh-pages branch |
| 22 | + contents: write |
| 23 | + |
| 24 | + steps: |
| 25 | + |
| 26 | + - name: Maximize build space |
| 27 | + run: | |
| 28 | + df -h |
| 29 | + sudo rm -rf /usr/share/dotnet |
| 30 | + sudo rm -rf /usr/local/lib/android |
| 31 | + sudo rm -rf /opt/ghc |
| 32 | + sudo rm -rf /opt/hostedtoolcache/CodeQL |
| 33 | + sudo docker image prune --all --force |
| 34 | + sudo rm -Rf ${JAVA_HOME_8_X64} |
| 35 | + sudo rm -Rf ${JAVA_HOME_11_X64} |
| 36 | + sudo rm -Rf ${JAVA_HOME_17_X64} |
| 37 | + sudo rm -Rf ${RUBY_PATH} |
| 38 | + df -h |
| 39 | +
|
| 40 | + - uses: actions/checkout@v4 |
| 41 | + - uses: Swatinem/rust-cache@v2 |
| 42 | + |
| 43 | + - name: Setup cargo-binstall |
| 44 | + env: |
| 45 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + run: | |
| 47 | + curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash |
| 48 | +
|
| 49 | + - name: Install oidc CLI |
| 50 | + env: |
| 51 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + run: | |
| 53 | + cargo binstall -y --force oidc-cli |
| 54 | +
|
| 55 | + - name: Install HTTPie |
| 56 | + run: | |
| 57 | + python -m pip install --upgrade pip wheel |
| 58 | + python -m pip install httpie |
| 59 | +
|
| 60 | + - name: Build |
| 61 | + run: | |
| 62 | + cargo build --bin trustd --release |
| 63 | +
|
| 64 | + - name: Run |
| 65 | + env: |
| 66 | + NO_COLOR: "true" |
| 67 | + run: |
| 68 | + nohup cargo run --bin trustd --release &> trustd.log & |
| 69 | + |
| 70 | + - name: Wait for the backend to be up |
| 71 | + run: | |
| 72 | + URL="http://localhost:8080/.well-known/trustify" |
| 73 | + TIMEOUT=300 # 5 minutes |
| 74 | + INTERVAL=5 # Interval between retries in seconds |
| 75 | + START_TIME=$(date +%s) |
| 76 | + |
| 77 | + while true; do |
| 78 | + # Check if the endpoint is up |
| 79 | + if curl -s --fail "$URL"; then |
| 80 | + echo |
| 81 | + echo "Endpoint is up!" |
| 82 | + exit 0 |
| 83 | + fi |
| 84 | + |
| 85 | + # Check if timeout has passed |
| 86 | + CURRENT_TIME=$(date +%s) |
| 87 | + ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) |
| 88 | + |
| 89 | + if [ "$ELAPSED_TIME" -ge "$TIMEOUT" ]; then |
| 90 | + echo "Timeout reached. Endpoint is still down." |
| 91 | + exit 1 |
| 92 | + fi |
| 93 | + |
| 94 | + echo "Endpoint is down. Retrying in $INTERVAL seconds..." |
| 95 | + sleep "$INTERVAL" |
| 96 | + done |
| 97 | +
|
| 98 | + - name: Setup OIDC |
| 99 | + run: | |
| 100 | + oidc create confidential trustify --issuer http://localhost:8090/realms/trustify --client-id walker --client-secret R8A6KFeyxJsMDBhjfHbpZTIF0GWt43HP --force # no-secret |
| 101 | +
|
| 102 | + - name: Run DS3 ingestion |
| 103 | + run: | |
| 104 | + .github/scripts/benchmark.sh |
| 105 | +
|
| 106 | + - name: Store benchmark result |
| 107 | + uses: benchmark-action/github-action-benchmark@v1 |
| 108 | + |
| 109 | + with: |
| 110 | + tool: 'customSmallerIsBetter' |
| 111 | + output-file-path: benchmark.json |
| 112 | + fail-on-alert: true |
| 113 | + # GitHub API token to make a commit comment |
| 114 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + # Enable Job Summary for PRs |
| 116 | + summary-always: true |
| 117 | + # Push and deploy GitHub pages branch automatically |
| 118 | + auto-push: ${{ github.event_name != 'pull_request' }} |
| 119 | + # Enable alert commit comment |
| 120 | + comment-on-alert: true |
| 121 | + # Mention @rhysd in the commit comment |
| 122 | + # alert-comment-cc-users: '@rhysd' |
| 123 | + |
| 124 | + - name: Upload container logs |
| 125 | + uses: actions/upload-artifact@v4 |
| 126 | + if: always() |
| 127 | + with: |
| 128 | + name: logs |
| 129 | + path: | |
| 130 | + trustd.log |
| 131 | + if-no-files-found: error |
0 commit comments