Workflow file for this run
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
name: Test Build and Call With Fake Register | ||
on: [push] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Python 3.x | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y openssl | ||
- name: Install Python Dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install requests | ||
- name: Create Dummy Certificates and Keys | ||
run: | | ||
mkdir -p ./data/certs | ||
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out ./data/certs/local-ca.key | ||
openssl req -x509 -new -nodes -key ./data/certs/local-ca.key -sha256 -days 3650 -out ./data/certs/factory_ca.pem -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" | ||
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out ./data/certs/server.key | ||
openssl req -new -key ./data/certs/server.key -out ./data/certs/server.csr -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" | ||
openssl x509 -req -in ./data/certs/server.csr -CA ./data/certs/factory_ca.pem -CAkey ./data/certs/local-ca.key -CAcreateserial -out ./data/certs/tls-crt -days 365 -sha256 | ||
ls -la ./data/certs | ||
- name: Build Docker Compose | ||
run: | | ||
docker-compose build | ||
- name: Run Docker Compose | ||
run: | | ||
docker-compose up -d | ||
sleep 30 | ||
- name: Execute Script. Expected to fail when the API be called | ||
run: | | ||
set +e | ||
output=$(python3 fake-lmp-device-register --registration-url "http://localhost:80/sign" --factory fake-test-sample 2>&1) | ||
exit_code=$? | ||
set -e | ||
# if [ $exit_code -ne 0 ]; then | ||
# echo "Non-zero exit code: $exit_code" | ||
# if echo "$output" | grep -q 'ConnectionResetError'; then | ||
# echo "Expected failure occurred." | ||
# else | ||
# echo "Unexpected failure occurred." | ||
# exit 1 | ||
# fi | ||
# fi | ||
echo "Output:" | ||
echo "$output" | ||
- name: Check relative /var/sota directory and pkey.pem file | ||
run: | | ||
if [[ -d "var/sota" && -f "var/sota/pkey.pem" ]]; then | ||
echo "Relative /var/sota directory exists and pkey.pem is present" | ||
else | ||
echo "Relative /var/sota directory or pkey.pem is missing" | ||
exit 1 | ||
fi | ||
ls -la var/sota/ | ||
- name: Output Docker Compose Logs | ||
if: always() | ||
run: | | ||
echo "Docker Compose Logs:" | ||
docker-compose logs | ||
- name: Shutdown Docker Compose | ||
if: always() | ||
run: | | ||
docker-compose ps | ||
docker-compose down |