forked from sandialabs/firewheel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide CI testing support (sandialabs#8)
This provides a starting point for converting our GitLab CI testing infrastructure to the GitHub Actions workflow. ### Workflow Upgrades To avoid duplication in the workflow scripts, I've created a new set of [composite actions](https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action) to install minimega, discovery, FIREWHEEL, and tox. We should hopefully be able to use these composite actions to dramatically simplify some of the CI scripts we had before. I've also upgraded the versions of referenced reusable versions where possible. ### Test Enhancements The unit tests have been upgraded to provide increased utility and work better through the FIREWHEEL interface: - Running the `firewheel test unit` helper now returns the appropriate exit code returned by pytest, which was previously unintentionally suppressed. - A new marker includes or excludes tests which depend on model components. - In service of that functionality, the tests now also make use of [pytest's built-in `-m` option](https://docs.pytest.org/en/stable/example/markers.html#marking-test-functions-and-selecting-them-for-a-run) to select marked tests for inclusion/exclusion rather than adding custom options. ### Bug Fixes This PR also fixes a few bugs in the current implementation: - This fixes a testing error identified by testing the FIREWHEEL deployment in an fresh installation (a hardcoded path in the `test_cli_completion.py` script). - Arguments passed to the helpers were not parsed correctly, ignoring quoted inputs and just splitting on spaces. This changes the helpers to use `shlex` for proper parsing.
- Loading branch information
1 parent
cd57db4
commit e803672
Showing
17 changed files
with
192 additions
and
91 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# A composite action to install discovery | ||
|
||
name: Prepare discovery | ||
|
||
description: Install discovery | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install discovery | ||
run: | | ||
wget https://github.com/mitchnegus/minimega-discovery/releases/download/firewheel-debian_faed761/discovery.deb | ||
sudo dpkg -i discovery.deb | ||
sudo chown -R $USER:minimega /opt/discovery | ||
shell: bash |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# A composite action to install, configure, and initialize FIREWHEEL. | ||
# This action assumes that minimega and discovery have already been installed. | ||
|
||
name: Prepare FIREWHEEL | ||
|
||
description: Install, configure, and initialize FIREWHEEL | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install FIREWHEEL | ||
run: | | ||
pip install --upgrade pip | ||
pip install . | ||
sudo ln -s $(which firewheel) /usr/local/bin/firewheel | ||
ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa" -N "" | ||
ssh-keyscan -t rsa $(hostname) >> $HOME/.ssh/known_hosts | ||
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys | ||
shell: bash | ||
- name: Configure FIREWHEEL | ||
run: | | ||
firewheel config set -s cluster.compute $(hostname) | ||
firewheel config set -s cluster.control $(hostname) | ||
firewheel config set -s grpc.hostname $GRPC_HOSTNAME | ||
firewheel config set -s minimega.experiment_interface $EXPERIMENT_INTERFACE | ||
firewheel config set -s logging.root_dir $LOG_DIR | ||
shell: bash | ||
- name: Initialize FIREWHEEL | ||
run: | | ||
firewheel init | ||
firewheel sync # will produce `chgrp` errors (but permissions are sufficient) | ||
firewheel start | ||
shell: bash |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# A composite action to install and initialize minimega | ||
|
||
name: Prepare minimega | ||
|
||
description: Install and initialize minimega | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install minimega | ||
run: | | ||
wget https://github.com/sandia-minimega/minimega/releases/download/2.9/minimega-2.9.deb | ||
sudo dpkg -i minimega-2.9.deb | ||
sudo chown -R $USER:minimega $MM_INSTALL_DIR | ||
sudo ln -s $MM_INSTALL_DIR/bin/minimega /usr/local/bin/minimega | ||
sudo ln -s $MM_INSTALL_DIR/bin/minimega /usr/local/bin/mm | ||
shell: bash | ||
- name: Initialize minimega | ||
run: | | ||
echo -n "" | sudo $MM_INSTALL_DIR/misc/daemon/minimega.init install | ||
sudo mkdir -p $(dirname $MINIMEGA_CONFIG) | ||
sudo sed -i "s|MINIMEGA_DIR=\"/opt/minimega/\"|MINIMEGA_DIR=\"$MM_INSTALL_DIR/\"|g" $MINIMEGA_CONFIG | ||
sudo sed -i "s|MM_RUN_PATH=\"/tmp/minimega\"|MM_RUN_PATH=\"$MM_BASE/\"|g" $MINIMEGA_CONFIG | ||
sudo sed -i "s|MM_MESH_DEGREE=0|MM_MESH_DEGREE=1|g" $MINIMEGA_CONFIG | ||
sudo sed -i "s|MM_LOG_LEVEL=\"error\"|MM_LOG_LEVEL=\"debug\"|g" $MINIMEGA_CONFIG | ||
sudo sed -i "s|MM_LOG_FILE=\"/tmp/minimega.log\"|MM_LOG_FILE=\"$LOG_DIR/minimega.log\"|g" $MINIMEGA_CONFIG | ||
sudo systemctl restart minimega | ||
sudo chown -R $USER:minimega $MM_BASE $LOG_DIR | ||
shell: bash |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# A composite action to prepare tox-based workflows | ||
|
||
name: Prepare tox | ||
|
||
description: Prepare tox-based workflows | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Ensure upgraded pip | ||
run: pip install --upgrade pip | ||
shell: bash | ||
- name: Install tox | ||
run: pip install tox | ||
shell: bash |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This workflow will install Python dependencies and run tests with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Testing | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
LOG_DIR: /var/log/firewheel | ||
MINIMEGA_CONFIG: /etc/minimega/minimega.conf | ||
# Set the FIREWHEEL environment variables | ||
EXPERIMENT_INTERFACE: lo | ||
MM_BASE: /tmp/minimega | ||
MM_INSTALL_DIR: /opt/minimega | ||
GRPC_HOSTNAME: localhost | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y tar net-tools procps uml-utilities \ | ||
openvswitch-switch qemu-kvm qemu-utils dnsmasq \ | ||
ntfs-3g iproute2 libpcap-dev | ||
- name: Prepare minimega | ||
uses: ./.github/actions/prepare-minimega | ||
- name: Prepare discovery | ||
uses: ./.github/actions/prepare-discovery | ||
- name: Prepare FIREWHEEL | ||
uses: ./.github/actions/prepare-firewheel | ||
- name: Run unit tests | ||
run: | | ||
firewheel test unit -m 'not long and not mcs' \ | ||
--cov --cov-report=term --cov-fail-under=60 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.