Skip to content

Commit

Permalink
build: use glances to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
akikanellis committed Apr 4, 2024
1 parent 83918ba commit dfcac62
Showing 1 changed file with 91 additions and 96 deletions.
187 changes: 91 additions & 96 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ name: Benchmark
- update-dependencies-molecule-24.x

jobs:
glances:
name: "Glances"
test-parallel-false:
name: "Test - Parallel: false"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cores: [1, 2, 3, 4]

steps:
- name: Free disk space
uses: jlumbroso/[email protected]

# - name: Free disk space
# uses: jlumbroso/[email protected]
#
- name: Checkout
# yamllint disable-line rule:line-length
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -37,19 +40,82 @@ jobs:
python-version: 3.12.2
cache: pip

- name: Update apt
run: sudo apt update

- name: Install test dependencies
run: sudo apt install vagrant virtualbox

- name: Install dependencies
run: just install-dependencies

- name: Install Glances
run: pip install glances

- name: Start Glances in background
id: start-glances
run: |
CSV_FILE=$(pwd)/glances.csv
CSV_FILE=$(pwd)/glances-parallel-false-cores-${{ matrix.cores }}.csv
glances --export=csv --export-csv-file=$CSV_FILE --quiet &
echo "pid=$!" >> "$GITHUB_OUTPUT"
echo "csv_path=$CSV_FILE" >> "$GITHUB_OUTPUT"
- name: Run
run: MOLECULE_CPUS=${{ matrix.cores }} just test

- name: Stop Glances
if: always()
run: |
kill ${{ steps.start-glances.outputs.pid }}
while kill -0 ${{ steps.start-glances.outputs.pid }} 2> /dev/null; do
echo "Waiting for Glances to stop..."
sleep 1
done
echo "Glances stopped successfully."
- name: Upload Glances CSV
if: always()
uses: actions/upload-artifact@v4
with:
name: glances-parallel-false-cores-${{ matrix.cores }}
path: ${{ steps.start-glances.outputs.csv_path }}

test-parallel-true:
name: "Test - Parallel: true"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
instance: [workstation-pop-os, server-nas, server-pi]
cores: [1, 2, 3, 4]

steps:
- name: Free disk space
uses: jlumbroso/[email protected]

- name: Checkout
# yamllint disable-line rule:line-length
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup just
# yamllint disable-line rule:line-length
uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
with:
# renovate: datasource=crate depName=just
just-version: 1.25.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Python
# yamllint disable-line rule:line-length
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
# renovate: datasource=docker depName=python versioning=docker
python-version: 3.12.2
cache: pip

- name: Update apt
run: sudo apt update

Expand All @@ -59,7 +125,24 @@ jobs:
- name: Install dependencies
run: just install-dependencies

- name: Install Glances
run: pip install glances

- name: Start Glances in background
id: start-glances
run: |
CSV_FILE=$(pwd)/glances-parallel-true-instance-${{ matrix.instance }}-cores-${{ matrix.cores }}.csv
glances --export=csv --export-csv-file=$CSV_FILE --quiet &
echo "pid=$!" >> "$GITHUB_OUTPUT"
echo "csv_path=$CSV_FILE" >> "$GITHUB_OUTPUT"
- name: Run
run: MOLECULE_CPUS=${{ matrix.cores }} just test --platform-name=${{ matrix.instance }}

- name: Stop Glances
if: always()
run: |
kill ${{ steps.start-glances.outputs.pid }}
while kill -0 ${{ steps.start-glances.outputs.pid }} 2> /dev/null; do
Expand All @@ -69,96 +152,8 @@ jobs:
echo "Glances stopped successfully."
- name: Upload Glances CSV
if: always()
uses: actions/upload-artifact@v4
with:
name: glances-metrics
name: glances-parallel-true-instance-${{ matrix.instance }}-cores-${{ matrix.cores }}
path: ${{ steps.start-glances.outputs.csv_path }}

# test-parallel-false:
# name: "Test - Parallel: false"
# runs-on: ubuntu-latest
# strategy:
# matrix:
# cores: [1, 2, 3, 4]
#
# steps:
# - name: Free disk space
# uses: jlumbroso/[email protected]
#
# - name: Checkout
# # yamllint disable-line rule:line-length
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
#
# - name: Setup just
# # yamllint disable-line rule:line-length
# uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
# with:
# # renovate: datasource=crate depName=just
# just-version: 1.25.2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Install Python
# # yamllint disable-line rule:line-length
# uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
# with:
# # renovate: datasource=docker depName=python versioning=docker
# python-version: 3.12.2
# cache: pip
#
# - name: Update apt
# run: sudo apt update
#
# - name: Install test dependencies
# run: sudo apt install vagrant virtualbox
#
# - name: Install dependencies
# run: just install-dependencies
#
# - name: Run
# run: MOLECULE_CPUS=${{ matrix.cores }} just test
#
# test-parallel-true:
# name: "Test - Parallel: true"
# runs-on: ubuntu-latest
# strategy:
# matrix:
# instance: [workstation-pop-os, server-nas, server-pi]
# cores: [1, 2, 3, 4]
#
# steps:
# - name: Free disk space
# uses: jlumbroso/[email protected]
#
# - name: Checkout
# # yamllint disable-line rule:line-length
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
#
# - name: Setup just
# # yamllint disable-line rule:line-length
# uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
# with:
# # renovate: datasource=crate depName=just
# just-version: 1.25.2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Install Python
# # yamllint disable-line rule:line-length
# uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
# with:
# # renovate: datasource=docker depName=python versioning=docker
# python-version: 3.12.2
# cache: pip
#
# - name: Update apt
# run: sudo apt update
#
# - name: Install test dependencies
# run: sudo apt install vagrant virtualbox
#
# - name: Install dependencies
# run: just install-dependencies
#
# - name: Run
# run: MOLECULE_CPUS=${{ matrix.cores }} just test --platform-name=${{ matrix.instance }}

0 comments on commit dfcac62

Please sign in to comment.