-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from thin-edge/chore-update-thin-edge.io
chore: update thin-edge.io and add tests
- Loading branch information
Showing
16 changed files
with
485 additions
and
67 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,37 @@ | ||
name: Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
VERSION: | ||
description: "Version" | ||
type: string | ||
default: "" | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: taiki-e/install-action@just | ||
|
||
- name: Publish images | ||
run: just build registry ${{ inputs.VERSION || github.ref_name }} |
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,111 @@ | ||
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 ] | ||
merge_group: | ||
jobs: | ||
approve: | ||
name: Approve | ||
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-latest | ||
steps: | ||
- name: Wait for approval | ||
run: echo "Approved" | ||
|
||
test: | ||
name: Test ${{ matrix.job.target }} | ||
runs-on: ubuntu-latest | ||
needs: approve | ||
environment: | ||
name: Test Auto | ||
env: | ||
COMPOSE_PROJECT_NAME: ci_${{ matrix.job.target }}_${{github.run_id}}_${{github.run_attempt || '1'}} | ||
DEVICE_ID: ci_${{ matrix.job.target }}_${{github.run_id}}_${{github.run_attempt || '1'}} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
job: | ||
- { target: tedge-container-bundle } | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }} | ||
|
||
- uses: taiki-e/install-action@just | ||
|
||
- uses: reubenmiller/setup-go-c8y-cli@main | ||
- name: install c8y-tedge extension | ||
run: c8y extension install thin-edge/c8y-tedge | ||
|
||
- name: create .env file | ||
run: | | ||
touch .env | ||
just init "$DEVICE_ID" | ||
echo "DEVICE_ID=$DEVICE_ID" >> .env | ||
echo 'C8Y_BASEURL="${{ secrets.C8Y_BASEURL }}"' >> .env | ||
C8Y_DOMAIN=$(echo "${{ secrets.C8Y_BASEURL }}" | sed 's|.*://||g') | ||
echo 'C8Y_USER="${{ secrets.C8Y_USER }}"' >> .env | ||
echo 'C8Y_PASSWORD="${{ secrets.C8Y_PASSWORD }}"' >> .env | ||
# env variables required by the container | ||
echo "TEDGE_C8Y_URL=$C8Y_DOMAIN" >> .env | ||
cat .env | ||
- name: Upload certificate | ||
run: | | ||
just upload | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' | ||
cache-dependency-path: | | ||
tests/requirements.txt | ||
- name: Install dependencies | ||
run: | | ||
just venv | ||
- name: Start demo | ||
run: | | ||
export DOCKER_USER="1000:101" | ||
just start -d | ||
- name: Run tests | ||
run: just test | ||
|
||
- name: Upload test results | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: reports | ||
path: output | ||
|
||
- name: Stop demo | ||
if: always() | ||
run: just stop -v | ||
|
||
- name: Cleanup Devices | ||
if: always() | ||
run: | | ||
just cleanup "$DEVICE_ID" | ||
- name: Send report to commit | ||
uses: joonvena/[email protected] | ||
with: | ||
gh_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
report_path: 'output' | ||
show_passed_tests: 'true' |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
.env | ||
device-certs/ | ||
*.tar | ||
.venv/ | ||
output/ |
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,6 @@ | ||
{ | ||
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3", | ||
"robot.language-server.python": "${workspaceFolder}/.venv/bin/python3", | ||
"robot.python.executable": "${workspaceFolder}/.venv/bin/python3", | ||
"python.envFile": "${workspaceFolder}/.env" | ||
} |
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 |
---|---|---|
@@ -1,35 +1,35 @@ | ||
#!/command/with-contenv sh | ||
# shellcheck shell=sh | ||
set -e | ||
# | ||
# Convert environment variables config to files | ||
# | ||
echo "Current User: $(whoami)" | ||
|
||
if [ -n "$CERTPRIVATE" ]; then | ||
echo "Writing thin-edge.io private key from env 'CERTPRIVATE' (decoding from base64) to file" >&2 | ||
CERT_FILE_KEY="$(tedge config get device.key_path)" | ||
printf '%s' "$CERTPRIVATE" | tr -d '"' | base64 -d > "$CERT_FILE_KEY" | ||
# | ||
# Note: Due to permissions problems, copy the secrets from the /run read-only path to /etc/tedge/device-certs/ | ||
# | ||
CERT_FILE_KEY="$(tedge config get device.key_path)" | ||
if [ -f /run/secrets/certificate_private_key ]; then | ||
cat /run/secrets/certificate_private_key > "$CERT_FILE_KEY" | ||
chmod 600 "$CERT_FILE_KEY" | ||
fi | ||
|
||
|
||
if [ -n "$CERTPUBLIC" ]; then | ||
echo "Writing thin-edge.io private key from env 'CERTPUBLIC' (decoding from base64) to file" >&2 | ||
CERT_FILE_PUB="$(tedge config get device.cert_path)" | ||
printf '%s' "$CERTPUBLIC" | tr -d '"' | base64 -d > "$CERT_FILE_PUB" | ||
CERT_FILE_PUB="$(tedge config get device.cert_path)" | ||
if [ -f /run/secrets/certificate_public_key ]; then | ||
cat /run/secrets/certificate_public_key > "$CERT_FILE_PUB" | ||
chmod 644 "$CERT_FILE_PUB" | ||
fi | ||
|
||
# Support variable set by go-c8y-cli | ||
if [ -n "$C8Y_DOMAIN" ] && [ -z "${TEDGE_C8Y_URL:-}" ]; then | ||
echo "Setting c8y.url from C8Y_DOMAIN env variable. $C8Y_DOMAIN" >&2 | ||
tedge config set c8y.url "$C8Y_DOMAIN" | ||
fi | ||
|
||
# | ||
# Connect the mappers (if they are configured and not already connected) | ||
# | ||
MAPPERS="c8y az aws" | ||
for MAPPER in $MAPPERS; do | ||
URL=$(tedge config get "${MAPPER}.url" 2>/dev/null) | ||
if [ -n "$URL" ]; then | ||
if ! tedge connect "$MAPPER" --test 2>/dev/null; then | ||
echo "Connecting $MAPPER" >&2 | ||
tedge reconnect "$MAPPER" ||: | ||
fi | ||
if tedge config get "${MAPPER}.url" 2>/dev/null; then | ||
tedge connect "$MAPPER" ||: | ||
fi | ||
done |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
files = [ | ||
{ type = "software-management", path = "/var/log/tedge/agent/software-*" }, | ||
{ type = "software-management", path = "/var/log/tedge/agent/workflow-software*" }, | ||
{ type = "shell", path = "/var/log/tedge/agent/c8y_Command-*" }, | ||
] |
Oops, something went wrong.
635b8f4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Robot Results
Passed Tests
Operations
Operations
Operations
Telemetry
Telemetry
Telemetry