Skip to content

fix: refactor plugin to use nodered api #21

fix: refactor plugin to use nodered api

fix: refactor plugin to use nodered api #21

Workflow file for this run

name: Test
on:
workflow_dispatch:
# Use a manual approval process before PR's are given access to
# the secrets which are required to run the integration tests.
# The PR code should be manually approved to see if it can be trusted.
# When in doubt, do not approve the test run.
# Reference: https://dev.to/petrsvihlik/using-environment-protection-rules-to-secure-secrets-when-building-external-forks-with-pullrequesttarget-hci
pull_request_target:
branches: [ main ]
push:
branches: [ main ]
merge_group:
jobs:
test:
name: Test
environment:
# For security reasons, all pull requests need to be approved first before granting access to secrets
# So the environment should be set to have a reviewer/s inspect it before approving it
name: ${{ github.event_name == 'pull_request_target' && 'Test Pull Request' || 'Test Auto' }}
runs-on: ubuntu-20.04
env:
COMPOSE_PROJECT_NAME: ci_${{github.run_id}}_${{github.run_attempt || '1'}}
DEVICE_ID: ci_${{github.run_id}}_${{github.run_attempt || '1'}}
steps:
# Checkout either the PR or the branch
- name: Checkout PR
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR. Only after the manual approval process
- name: Checkout
uses: actions/checkout@v3
if: ${{ github.event_name != 'pull_request_target' }}
- name: create .env file
run: |
touch .env
echo "DEVICE_ID=$DEVICE_ID" >> .env
echo 'C8Y_BASEURL="${{ secrets.C8Y_BASEURL }}"' >> .env
echo 'C8Y_USER="${{ secrets.C8Y_USER }}"' >> .env
echo 'C8Y_PASSWORD="${{ secrets.C8Y_PASSWORD }}"' >> .env
cat .env
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
tests/requirements.txt
- uses: extractions/setup-just@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
just venv
- name: Start demo
run: |
just up
just bootstrap --no-prompt
- name: Run tests
run: just test
- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: reports
path: output
- name: Stop demo
if: always()
run: just down-all
- name: Install go-c8y-cli
if: always()
run: |
mkdir -p "$HOME/.local/bin"
curl -LSs https://github.com/reubenmiller/go-c8y-cli/releases/download/v2.22.4/c8y_linux_$(dpkg --print-architecture) -o "$HOME/.local/bin/c8y"
chmod +x "$HOME/.local/bin/c8y"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Cleanup Devices
if: always()
run: |
just cleanup "$DEVICE_ID"
generate_report:
name: Publish report
if: ${{ always() && github.event_name == 'pull_request_target' }}
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download reports
uses: actions/download-artifact@v3
with:
name: reports
path: reports
- name: Send report to commit
uses: joonvena/robotframework-reporter-action@v2.1
with:
gh_access_token: ${{ secrets.GITHUB_TOKEN }}