Normalise snap/snapcraft.yaml with yq #201
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: Build | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch to run the workflow on' | |
required: true | |
default: 'master' | |
# This allows a subsequently queued workflow run to interrupt previous runs | |
concurrency: | |
group: snap-pelion-edge-${{ github.event.pull_request.head.label || github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-snap: | |
runs-on: [ "self-hosted", "edge-builder" ] | |
timeout-minutes: 40 | |
steps: | |
- name: Enable write on all files | |
run: chmod a+w -R . | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
# Use the branch specified by the workflow_dispatch input or the pull_request event | |
ref: ${{ github.event.inputs.branch || github.event.pull_request.head.ref }} | |
- name: Copy mbed_cloud_dev_credentials.c | |
env: | |
MBED_CLOUD_DEV_CREDENTIALS: ${{ secrets.MBED_CLOUD_DEV_CREDENTIALS_SNAP_CI }} | |
run: | | |
echo "$MBED_CLOUD_DEV_CREDENTIALS" > mbed_cloud_dev_credentials.c | |
- name: Copy update_default_resources.c | |
env: | |
UPDATE_DEFAULT_RESOURCES: ${{ secrets.UPDATE_DEFAULT_RESOURCES_SNAP_CI }} | |
run: | | |
echo "$UPDATE_DEFAULT_RESOURCES" > update_default_resources.c | |
- name: Build Docker image | |
run: | | |
docker build --no-cache -f Dockerfile --label snapcore/snapcraft --tag ${USER}/snapcraft:latest . | |
- name: Build snap | |
run: | | |
# If previous run failed, set everything to write mode. | |
chmod a+w -R . | |
docker run --rm -v "$PWD":/build -w /build ${USER}/snapcraft:latest bash -c "sudo apt-get update && snapcraft --debug" | |
# The build left files with no write rights, which ruins next test run | |
chmod a+w -R . | |
- name: Archive the snap-binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pelion-edge-amd64.snap | |
path: ./pelion-edge*.snap | |
if-no-files-found: error | |
- name: Archive connect.sh | |
uses: actions/upload-artifact@v3 | |
with: | |
name: connect.sh | |
path: ./connect.sh | |
if-no-files-found: error | |
test: | |
runs-on: ubuntu-22.04 | |
needs: build-snap | |
timeout-minutes: 40 | |
env: | |
ACCESS_KEY: ${{ secrets.IZUMA_ACCESS_KEY }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
# Use the branch specified by the workflow_dispatch input or the pull_request event | |
ref: ${{ github.event.inputs.branch || github.event.pull_request.head.ref }} | |
- name: Check out scripts-internal & e2e tests repos | |
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/e2e-edge-test-suite | |
git clone [email protected]:PelionIoT/scripts-internal.git | |
ls -al | |
- name: Set up Python v3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: v3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r e2e-edge-test-suite/requirements.txt | |
sudo apt install virtualenv | |
curl -LO https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl | |
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl | |
kubectl version --client | |
- name: Get pelion-edge.snap from storage | |
uses: actions/download-artifact@v3 | |
with: | |
name: pelion-edge-amd64.snap | |
path: e2e-edge-test-suite | |
- name: Get connect.sh from storage | |
uses: actions/download-artifact@v3 | |
with: | |
name: connect.sh | |
path: e2e-edge-test-suite | |
- name: Install snap as sudo and test | |
run: | | |
snapfile=$(ls e2e-edge-test-suite/*.snap) | |
sudo scripts-internal/snap/snap-install.sh -s $snapfile | |
sleep 5 | |
sudo snap restart pelion-edge | |
sleep 5 | |
snap services | |
snap list | |
pelion-edge.help | |
pelion-edge.edge-info | |
pelion-edge.version | |
pelion-edge.edge-testnet | |
pelion-edge.curl --version | |
- name: Check snap-pelion-edge versions | |
run: | | |
sudo snap install yq | |
snapcraftyamlver=$(yq -r ".version" <snap/snapcraft.yaml |sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g") | |
version=$(pelion-edge.version |grep snap-pelion-edge | awk -F' ' '{ print $NF }') | |
if [[ "$snapcraftyamlver" != "$version" ]]; then | |
echo "FAIL - Snapcraft.yaml and pelion-edge.version versions differ: $snapcraftyamlver vs. $version" | |
exit 1 | |
fi | |
snapver=$(snap list |grep "pelion-edge" | awk -F' ' '{ print $2 }') | |
if [[ "$snapcraftyamlver" != "$snapver" ]]; then | |
echo "FAIL - Snapcraft.yaml and snap list versions differ: '$snapcraftyamlver' vs. '$snapver'" | |
exit 1 | |
fi | |
infover=$(pelion-edge.edge-info |grep "Pelion Edge Version:" | awk -F' ' '{ print $NF }' |sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" ) | |
if [[ "$snapcraftyamlver" != "$infover" ]]; then | |
echo "FAIL - Snapcraft.yaml and pelion-edge.edge-info versions differ: '$snapcraftyamlver' vs. '$infover'" | |
exit 1 | |
fi | |
# Disabled for now - reboot is required to get installation working correctly, | |
# we cannot however reboot a GitHub runner mid-job. | |
# - name: Run snap-test | |
# if: ${{ failure() }} || ${{ success() }} | |
# run: | | |
# cd e2e-edge-test-suite | |
# ../scripts-internal/snap/snap-test.sh -a ${{ secrets.IZUMA_ACCESS_KEY }} | |
- name: Remove snap | |
if: always() | |
run: | | |
sudo scripts-internal/snap/snap-remove.sh -a ${{ secrets.IZUMA_ACCESS_KEY }} -s pelion-edge | |
# - name: Archive the pytest.log | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: pytest.log | |
# path: e2e-edge-test-suite/pytest.log | |
# if-no-files-found: error | |
# - name: Publish Test Results | |
# uses: EnricoMi/publish-unit-test-result-action@v2 | |
# if: always() | |
# with: | |
# files: | | |
# results.xml | |
run-pysh-check-no-more-lines: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: sudo apt-get install black pycodestyle pydocstyle shellcheck python3 | |
- name: Set GitHub access token via git config | |
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" | |
- run: git clone [email protected]:PelionIoT/scripts-internal.git | |
- run: | | |
echo . >scripts-internal/.nopyshcheck | |
scripts-internal/ci/more-lines-checker.sh dev ${{ github.ref_name }} "scripts-internal/pysh/pysh-check.sh --workdir ." | |
yamllint-snapcraft-yaml: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: sudo apt-get install yamllint | |
- run: yamllint -c lint-config.yaml snap/snapcraft.yaml |