Skip to content

Commit

Permalink
Merge pull request #110 from thin-edge/ci-streamline-test-workflow
Browse files Browse the repository at this point in the history
ci: streamline test workflow
  • Loading branch information
reubenmiller authored Oct 5, 2024
2 parents 8e82a76 + 6942f81 commit 8fe2f04
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 65 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:
# 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:
approve:
Expand Down Expand Up @@ -45,15 +43,11 @@ jobs:

steps:
# Checkout either the PR or the branch
- name: Checkout PR
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
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@v4
if: ${{ github.event_name != 'pull_request_target' }}
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}
fetch-depth: 0

- uses: reubenmiller/setup-go-c8y-cli@main
- name: install c8y-tedge extension
Expand Down Expand Up @@ -106,7 +100,7 @@ jobs:
case "${{matrix.job.bootstrap}}" in
script)
just IMAGE=${{matrix.job.target}} prepare-up
just IMAGE=${{matrix.job.target}} up
just IMAGE=${{matrix.job.target}} up --build=false
just IMAGE=${{matrix.job.target}} bootstrap --no-prompt
;;
Expand All @@ -127,7 +121,7 @@ jobs:
*)
just IMAGE=${{matrix.job.target}} prepare-up
just IMAGE=${{matrix.job.target}} up
just IMAGE=${{matrix.job.target}} up --build=false
echo "Skipping bootstrapping"
;;
esac
Expand Down
41 changes: 1 addition & 40 deletions images/alpine-s6/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,5 @@
#!/bin/sh
set -e

SHOULD_PROMPT=${SHOULD_PROMPT:-1}
CAN_PROMPT=0

#
# Detect if the shell is running in interactive mode or not
if [ -t 0 ]; then
CAN_PROMPT=1
else
CAN_PROMPT=0
fi

prompt_value() {
user_text="$1"
value="$2"

if [ "$SHOULD_PROMPT" = 1 ] && [ "$CAN_PROMPT" = 1 ]; then
printf "\n%s (%s): " "$user_text" "${value:-not set}" >&2
read -r user_input
if [ -n "$user_input" ]; then
value="$user_input"
fi
fi
echo "$value"
}

if [ -z "$TEDGE_MQTT_DEVICE_TOPIC_ID" ]; then
if [ -z "$C8Y_USER" ]; then
C8Y_USER=$(prompt_value "Enter your Cumulocity IoT user" "$C8Y_USER")
fi

if [ -z "$C8Y_USER" ]; then
echo "C8Y_USER is not set"
exit 1
fi

if [ -n "$C8Y_PASSWORD" ]; then
C8YPASS="$C8Y_PASSWORD" tedge cert upload c8y --user "$C8Y_USER"
else
tedge cert upload c8y --user "$C8Y_USER"
fi
tedge cert upload c8y
fi
2 changes: 1 addition & 1 deletion images/alpine-s6/mosquitto/mosquitto-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi
#
# Upload cert if credentials are available
if [ -n "$C8Y_PASSWORD" ] && [ -n "$C8Y_USER" ]; then
env C8YPASS="$C8Y_PASSWORD" tedge cert upload c8y --user "$C8Y_USER" ||:
tedge cert upload c8y --user "$C8Y_USER" ||:
fi

# Wait until the device has been registered before starting the bridge,
Expand Down
15 changes: 2 additions & 13 deletions images/common/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,8 @@ bootstrap_c8y() {
echo "Setting c8y.url to $C8Y_BASEURL"
sudo tedge config set c8y.url "$C8Y_BASEURL"

C8Y_USER=$(prompt_value "Enter your Cumulocity user" "$C8Y_USER")

if [ -n "$C8Y_USER" ]; then
echo "Uploading certificate to Cumulocity using tedge"
if [ -n "$C8Y_PASSWORD" ]; then
C8YPASS="$C8Y_PASSWORD" tedge cert upload c8y --user "$C8Y_USER"
else
echo ""
tedge cert upload c8y --user "$C8Y_USER"
fi
else
fail "When manually bootstrapping you have to upload the certificate again as the device certificate is recreated"
fi
echo "Uploading certificate to Cumulocity using tedge"
tedge cert upload c8y

# Grace period for the server to process the certificate
# but it is not critical for the connection, as the connection
Expand Down

4 comments on commit 8fe2f04

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
11 0 2 11 100 48.299s

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
7 0 0 7 100 44.942s

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
14 0 0 14 100 59.757s

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
26 0 2 26 100 3m4.248s

Please sign in to comment.