Skip to content

change caching setup and comment both artifiacts #30

change caching setup and comment both artifiacts

change caching setup and comment both artifiacts #30

name: Benchmark Test
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
# give permissions to write a comment on the pull request and to read artifacts
permissions:
pull-requests: write
actions: read
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_wolfssl:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
wolfssl: [ master ]
name: Build wolfssl
runs-on: ${{ matrix.os }}
timeout-minutes: 4
steps:
- name: Checking cache for wolfssl
uses: actions/cache@v4
id: cache-wolfssl
with:
path: build-dir/
key: wolfssh-sshd-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
lookup-only: true
- name: Checkout, build, and install wolfssl
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
uses: wolfSSL/actions-build-autotools-project@v1
with:
repository: wolfssl/wolfssl
ref: ${{ matrix.wolfssl }}
path: wolfssl
configure: --enable-all
check: false
install: true
build_wolfssh:
needs:
- build_wolfssl
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
wolfssl: [ master ]
name: Collect SFTP performance
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- name: Checking cache for wolfssl
uses: actions/cache@v4
with:
path: build-dir/
key: wolfssh-sshd-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
fail-on-cache-miss: true
- uses: actions/checkout@v4
with:
path: wolfssh/
- name: autogen
working-directory: ./wolfssh/
run: ./autogen.sh
- name: configure
working-directory: ./wolfssh/
run : |
./configure --enable-all LDFLAGS="-L${{ github.workspace }}/build-dir/lib" CPPFLAGS="-I${{ github.workspace }}/build-dir/include -DWOLFSSH_NO_FPKI -DWOLFSSH_NO_SFTP_TIMEOUT -DWOLFSSH_MAX_SFTP_RW=4000000 -DMAX_PATH_SZ=120 -DEXAMPLE_SFTP_BENCHMARK"
- name: make
working-directory: ./wolfssh/
run: make
- name: Get Saved OpenSSH Upload Results
id: cache-upload
uses: actions/cache@v4
with:
path: wolfssh/openssh-average-download.csv
key: openssh-average-download.csv
fail-on-cache-miss: false
- name: Get Saved OpenSSH Download Results
id: cache-download
uses: actions/cache@v4
with:
path: wolfssh/openssh-average-upload.csv
key: openssh-averavge-upload.csv
fail-on-cache-miss: false
- name: Install gnuplot
run: sudo apt-get install gnuplot
- name: Setup OpenSSH Test Server
working-directory: ./wolfssh/
run: |
sudo apt-get install openssh-server
mkdir ~/.ssh
chmod 700 ~/.ssh
echo "AuthorizedKeysFile $PWD/keys/hansel-key-ecc.pub" >> sshd-config-test.txt
echo "PubkeyAuthentication yes" >> sshd-config-test.txt
echo "Subsystem sftp internal-sftp" >> sshd-config-test.txt
echo "KbdInteractiveAuthentication no" >> sshd-config-test.txt
sed -i.bak "s/hansel/$USER/" ./keys/hansel-key-ecc.pub
chmod 600 ./keys/hansel-key-*.pem
chmod 600 ./keys/hansel-key-*.pub
sudo mkdir -p /run/sshd
sudo chmod 755 /run/sshd
sudo /usr/sbin/sshd -p 22222 -f sshd-config-test.txt -E $PWD/sshd-log.txt
cat sshd-config-test.txt
ps -e | grep sshd
- name: Run SFTP client benchmark
working-directory: ./wolfssh/
timeout-minutes: 5
run: |
./scripts/get-sftp-benchmark.sh 22222
- name: Store Upload Speed PNG
uses: actions/upload-artifact@v4
with:
name: upload-results-pr${{ github.event.pull_request.number }}.png
path: wolfssh/upload-results.png
retention-days: 2
- name: Store Download Speed PNG
uses: actions/upload-artifact@v4
with:
name: download-results-pr${{ github.event.pull_request.number }}.png
path: wolfssh/download-results.png
retention-days: 2
- name: Upload OpenSSH Download Results
if: steps.cache-download.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: wolfssh/openssh-average-download.csv
key: openssh-average-download.csv
- name: Upload OpenSSH Upload Results
if: steps.cache-upload.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: wolfssh/openssh-average-upload.csv
key: openssh-average-upload.csv
- name: Comment on PR about performance
env:
GITHUB_URL: ${{ github.event.pull_request.comments_url }}
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
RUN_ID: ${{ github.run_id }}
run: |
# Get both artifact IDs
DOWNLOAD_ARTIFACT=$(gh api repos/${{ github.repository }}/actions/artifacts \
--jq '.artifacts[] | select(.name | contains("download-results-pr")) | .id')
UPLOAD_ARTIFACT=$(gh api repos/${{ github.repository }}/actions/artifacts \
--jq '.artifacts[] | select(.name | contains("upload-results-pr")) | .id')
# Create the comment with direct link to download
curl -X POST \
$GITHUB_URL \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
-d "{\"body\":\"Performance test results:\n\n- [Download Results](https://github.com/${{ github.repository }}/actions/runs/$RUN_ID/artifacts/$DOWNLOAD_ARTIFACT)\n- [Upload Results](https://github.com/${{ github.repository }}/actions/runs/$RUN_ID/artifacts/$UPLOAD_ARTIFACT)\"}"
- name: Print logs if failed
working-directory: ./wolfssh/
if: failure()
run: |
sudo cat sshd-log.txt
cat log.csv