Skip to content

Commit

Permalink
Merge pull request #53 from PelionIoT/no-git-redirect
Browse files Browse the repository at this point in the history
Remove git re-direct, add build test
  • Loading branch information
JanneKiiskila authored Oct 29, 2024
2 parents 2160f81 + 54b82bc commit 9a3d886
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 10 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: build

on:
push:
paths-ignore:
- '**/*.md'
workflow_dispatch:
schedule:
# Once in week 3:33 on Sunday (0 and 7 are Sunday)
- cron: '33 3 * * 0'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: pep-build-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
pep-build:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- uses: actions/checkout@v4
- name: Install docker-compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
dver=$(docker-compose version)
echo "$dver"
echo "$dver" >> $GITHUB_STEP_SUMMARY
- name: Configure fcu
run: |
mkdir fcu_config
cd fcu_config
echo "${{ secrets.FCU_KEYS_TAR_GZ_B64 }}" > fcu_keys.tar.gz.b64
base64 -d fcu_keys.tar.gz.b64 > fcu_keys.tar.gz
tar -xzf fcu_keys.tar.gz
- name: Download the factory_configurator_utility.zip (as the repo does not have it)
run: |
cd fcu_config
mkdir config
cp fcu.yml config/fcu.yml
curl -X GET \
https://api.us-east-1.mbedcloud.com/downloads/fcu/factory_configurator_utility.zip \
-H "Authorization: Bearer ${{ secrets.EDGE_EXAMPLES_API_KEY }}" \
-o factory_configurator_utility.zip
- name: Build
run: docker-compose build --build-arg fcu_config=fcu_config
- name: Start the docker
run: |
docker-compose up &
- name: Check the processes
run: |
retries=30
max_attempts=6 # 60 seconds
remaining_checks=${max_attempts}
attempt=1
while [[ "${attempt}" -le "${max_attempts}" ]]; do
procs=$(docker-compose ps --services)
if [[ -n "${procs}" ]]; then
echo "docker-compose up is running with $procs..."
break
fi
if [[ "${attempt}" -eq "${max_attempts}" ]]; then
echo "FAIL: docker-compose up not getting started..."
return 1
fi
attempt=$((attempt + 1))
sleep 10
done
procs=$(docker-compose ps)
echo "# docker-compose ps:"
echo "$procs"
# Check we find mongo in $procs
mongo=$(echo "$procs" | grep mongo)
if [[ -z "$mongo" ]]; then
echo "Failed to start mongoDB"
exit 1
fi
state=$(echo "$mongo" | grep "Up")
if [[ -z "$state" ]]; then
echo "Failed to get mongoDB container up."
exit 1
fi
api=$(echo "$procs" | grep api-server)
if [[ -z "$api" ]]; then
echo "Failed to start api-server"
exit 1
fi
state=$(echo "$api" | grep "Up")
if [[ -z "$state" ]]; then
echo "Failed to get api-server container up."
exit 1
fi
- name: Get the logs
run: |
logs=$(docker-compose logs)
echo "# docker-compose logs:" >> $GITHUB_STEP_SUMMARY
echo $logs >> $GITHUB_STEP_SUMMARY
# MongoDB only creates the database once you inject some data to it
# - name: Inspect mongo db volume
# run: |
# mong=$(docker volume inspect pelion-edge-provisioner_mongo_data)
# echo "# docker volume inspect pelion-edge-provisioner_mongo_data:" >> $GITHUB_STEP_SUMMARY
# echo $mong >> $GITHUB_STEP_SUMMARY
- name: Stop the container
run: docker-compose down

19 changes: 10 additions & 9 deletions .github/workflows/pysh-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Pysh-check
run-name: ${{ github.actor }} Pull Request pysh-check
on: [push]
on:
push:
workflow_dispatch:

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
Expand All @@ -11,15 +13,14 @@ jobs:
run-pysh-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# Install pyshcheck tooling
- name: Install (apt-get) dependencies
run: sudo apt-get install black pycodestyle pydocstyle shellcheck python3
# git instead of rules to use access token
- name: Clone scripts-internal
run: |
git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github.com/".insteadOf "[email protected]:"
git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github".insteadOf "https://github"
git clone [email protected]:PelionIoT/scripts-internal.git
echo . >scripts-internal/.nopyshcheck
- uses: actions/checkout@v4
with:
repository: 'PelionIoT/scripts-internal'
token: ${{ secrets.ACCESS_TOKEN }}
path: 'scripts-internal'
- run: touch scripts-internal/.pyshcheck
- run: scripts-internal/pysh-check/pysh-check.sh --workdir .
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

The Izuma Edge provisioning (pep) tool lets you automate the gateway provisioning flow. For more information, please see the [documentation](https://developer.izumanetworks.com/docs/device-management-edge/latest/provisioning/index.html).

## API documentation

You can view the API documentation (swagger) for the pep-server via http://localhost:5151/docs/ once your docker is running.

## Tests

Run `factory-configurator-client-example`, if it is not installed, follow [the document about building the FCC example on native Linux](https://developer.izumanetworks.com/docs/device-management-provision/latest/ft-demo/building-demo.html#native-linux) for the detailed steps. Below are the quick steps that install the program. For example, in the []`meta-edge`](https://github.com/PelionIoT/meta-edge) project you can find the precompiled binary located at `/edge/system/bin/factory-configurator-client-armcompiled.elf`.
Run `factory-configurator-client-example`, if it is not installed, follow [the document about building the FCC example on native Linux](https://developer.izumanetworks.com/docs/device-management-provision/latest/ft-demo/building-demo.html#native-linux) for the detailed steps. Below are the quick steps that install the program. For example, in the [`meta-edge`](https://github.com/PelionIoT/meta-edge) project you can find the precompiled binary located at `/edge/system/bin/factory-configurator-client-armcompiled.elf`.

<span class="notes">**Note:** This tool is not supported on macOS, so if you are running the server on macOS, you can't test pep CLI on the same machine.</span>

Expand Down

0 comments on commit 9a3d886

Please sign in to comment.