From dbfc5aaf54ea57ad64479f2074f0396a89bd5392 Mon Sep 17 00:00:00 2001 From: Umberto Baldi <u.baldi@arduino.cc> Date: Wed, 23 Jun 2021 17:21:31 +0200 Subject: [PATCH 1/8] add shell script to easily copy dir structure to s3 --- generator/s3Copy.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 generator/s3Copy.sh diff --git a/generator/s3Copy.sh b/generator/s3Copy.sh new file mode 100755 index 00000000..fc6f78a2 --- /dev/null +++ b/generator/s3Copy.sh @@ -0,0 +1,11 @@ +path=$1 # the path of the directory where the files and directories that need to be copied are located +s3Dir=$2 # the s3 bucket path + +for entry in "$path"/*; do + name=`echo $entry | sed 's/.*\///'` # getting the name of the file or directory + if [[ -d $entry ]]; then # if it is a directory + aws s3 cp --recursive "$name" "$s3Dir/$name/" + else # if it is a file + aws s3 cp "$name" "$s3Dir/" --exclude "generator.py" --exclude "raw_boards.json" --exclude "s3Copy.sh" + fi +done From 691e5e1f732721a62e8a1a6936c12a2a52dd257e Mon Sep 17 00:00:00 2001 From: Umberto Baldi <u.baldi@arduino.cc> Date: Wed, 23 Jun 2021 17:23:14 +0200 Subject: [PATCH 2/8] add generated content to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 56400012..980e4804 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ coverage_*.txt /dist __pycache__/ +/generator/boards/ +/generator/firmwares/ # Misc. .DS_Store From 768951240dda53f20e3947214bd3f2a005a732c2 Mon Sep 17 00:00:00 2001 From: umbynos <umberto.baldi@edu.unito.it> Date: Wed, 30 Jun 2021 18:50:41 +0200 Subject: [PATCH 3/8] remove code duplication --- Taskfile.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 62a18525..655199b8 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -93,7 +93,7 @@ tasks: desc: Run integration tests cmds: - task: build - - poetry install --no-root + - task: poetry:install-deps - poetry run pytest test check: @@ -123,13 +123,13 @@ tasks: python:lint: desc: Lint Python code cmds: - - poetry install --no-root + - task: poetry:install-deps - poetry run flake8 python:format: desc: Automatically formats Python files cmds: - - poetry install --no-root + - task: poetry:install-deps - poetry run black . vars: From becf846bc6ff585b89a381af11135b5556a44297 Mon Sep 17 00:00:00 2001 From: umbynos <umberto.baldi@edu.unito.it> Date: Wed, 30 Jun 2021 18:51:27 +0200 Subject: [PATCH 4/8] add python3 shebang and chmod +x --- generator/generator.py | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 generator/generator.py diff --git a/generator/generator.py b/generator/generator.py old mode 100644 new mode 100755 index 89536efa..6d54e6ab --- a/generator/generator.py +++ b/generator/generator.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import argparse import subprocess import sys From d1dd34cd32bef0191a4f807ee67dfbba00d5b26b Mon Sep 17 00:00:00 2001 From: umbynos <umberto.baldi@edu.unito.it> Date: Wed, 30 Jun 2021 18:53:42 +0200 Subject: [PATCH 5/8] add first prototype of the generate-index workflow (still to test) --- .github/workflows/generate-index.yml | 72 ++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/generate-index.yml diff --git a/.github/workflows/generate-index.yml b/.github/workflows/generate-index.yml new file mode 100644 index 00000000..8196a861 --- /dev/null +++ b/.github/workflows/generate-index.yml @@ -0,0 +1,72 @@ +name: Generate Index + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + pull_request: + branches: + - umbynos/index_generation + push: + paths: + - "generator/**" + - "firmwares/**" + - "poetry.lock" + - "pyproject.toml" + workflow_dispatch: + repository_dispatch: + +jobs: + generate-index: + runs-on: ubuntu-latest + defaults: + run: + working-directory: generator + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Taskfile + uses: arduino/setup-task@v1 + + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: Install Poetry + run: pip install poetry + + - name: Install Arduino CLI + uses: arduino/setup-arduino-cli@v1 + + - name: Install platforms + run: | + arduino-cli core update-index -v + arduino-cli version + arduino-cli core install arduino:samd@${{ env.SAMD_V }} -v + arduino-cli core install arduino:megaavr@${{ env.MEGAAVR_V }} -v + arduino-cli core install arduino:mebd_nano@${{ env.MBED_NANO_V }} -v + env: + SAMD_V: 1.18.11 + MEGAAVR_V: 1.8.7 + MBED_NANO_V: 2.2.0 + + - name: Install dependencies + run: task poetry:install-deps + + - name: Generate index + run: ./generator.py -a $(which arduino-cli) + + - name: Import GPG key + run: | + echo "${{ secrets.GPG_PRIVATE_KEY }}" > private.key + gpg --import --batch --passphrase ${{ secrets.PASSPHRASE }} private.key + + - name: sign the json + run: gpg --output boards/module_firmware_index.json.sig --detach-sign boards/module_firmware_index.json + + - name: create the gzip + run: gzip --keep boards/module_firmware_index.json + + - name: s3 sync + run: ./s3Copy.sh . s3://arduino-downloads-prod-beagle/arduino-fwuploader From abfbcfae0d40bf51f1e4f1fae858ea0b8dea0254 Mon Sep 17 00:00:00 2001 From: Umberto Baldi <u.baldi@arduino.cc> Date: Fri, 2 Jul 2021 18:24:17 +0200 Subject: [PATCH 6/8] various fixes, should work now --- .github/workflows/generate-index.yml | 36 ++++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/generate-index.yml b/.github/workflows/generate-index.yml index 8196a861..e161a508 100644 --- a/.github/workflows/generate-index.yml +++ b/.github/workflows/generate-index.yml @@ -2,15 +2,14 @@ name: Generate Index # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows on: - pull_request: - branches: - - umbynos/index_generation push: + branches: paths: - "generator/**" - "firmwares/**" - "poetry.lock" - "pyproject.toml" + - ".github/workflows/generate-index.yml" workflow_dispatch: repository_dispatch: @@ -31,7 +30,7 @@ jobs: - name: Install Python uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "3.9" - name: Install Poetry run: pip install poetry @@ -45,28 +44,39 @@ jobs: arduino-cli version arduino-cli core install arduino:samd@${{ env.SAMD_V }} -v arduino-cli core install arduino:megaavr@${{ env.MEGAAVR_V }} -v - arduino-cli core install arduino:mebd_nano@${{ env.MBED_NANO_V }} -v + arduino-cli core install arduino:mbed_nano@${{ env.MBED_NANO_V }} -v env: - SAMD_V: 1.18.11 + SAMD_V: 1.8.11 MEGAAVR_V: 1.8.7 MBED_NANO_V: 2.2.0 - name: Install dependencies - run: task poetry:install-deps + run: | + cd $GITHUB_WORKSPACE + task poetry:install-deps - name: Generate index - run: ./generator.py -a $(which arduino-cli) - + run: poetry run ./generator.py -a $(which arduino-cli) + + # fix `gpg: signing failed: Inappropriate ioctl for device` + # https://github.com/keybase/keybase-issues/issues/2798 - name: Import GPG key run: | - echo "${{ secrets.GPG_PRIVATE_KEY }}" > private.key - gpg --import --batch --passphrase ${{ secrets.PASSPHRASE }} private.key - + echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 -di > private.key + gpg --batch --import --passphrase "${{ secrets.PASSPHRASE }}" private.key + echo "GPG_TTY=$(tty)" >> $GITHUB_ENV + + # disable gpg pass prompt + # https://stackoverflow.com/questions/49072403/suppress-the-passphrase-prompt-in-gpg-command - name: sign the json - run: gpg --output boards/module_firmware_index.json.sig --detach-sign boards/module_firmware_index.json + run: gpg --pinentry-mode=loopback --passphrase "${{ secrets.PASSPHRASE }}" --output boards/module_firmware_index.json.sig --detach-sign boards/module_firmware_index.json - name: create the gzip run: gzip --keep boards/module_firmware_index.json - name: s3 sync run: ./s3Copy.sh . s3://arduino-downloads-prod-beagle/arduino-fwuploader + env: + AWS_REGION: "us-east-1" # or https://github.com/aws/aws-cli/issues/5623 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} \ No newline at end of file From daf42315d68249f2e1119a318325fe0bd577a08d Mon Sep 17 00:00:00 2001 From: umbynos <umberto.baldi@edu.unito.it> Date: Tue, 6 Jul 2021 09:56:24 +0200 Subject: [PATCH 7/8] apply formatting --- .github/workflows/generate-index.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/generate-index.yml b/.github/workflows/generate-index.yml index e161a508..048416bd 100644 --- a/.github/workflows/generate-index.yml +++ b/.github/workflows/generate-index.yml @@ -57,7 +57,7 @@ jobs: - name: Generate index run: poetry run ./generator.py -a $(which arduino-cli) - + # fix `gpg: signing failed: Inappropriate ioctl for device` # https://github.com/keybase/keybase-issues/issues/2798 - name: Import GPG key @@ -65,8 +65,8 @@ jobs: echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 -di > private.key gpg --batch --import --passphrase "${{ secrets.PASSPHRASE }}" private.key echo "GPG_TTY=$(tty)" >> $GITHUB_ENV - - # disable gpg pass prompt + + # disable gpg pass prompt # https://stackoverflow.com/questions/49072403/suppress-the-passphrase-prompt-in-gpg-command - name: sign the json run: gpg --pinentry-mode=loopback --passphrase "${{ secrets.PASSPHRASE }}" --output boards/module_firmware_index.json.sig --detach-sign boards/module_firmware_index.json @@ -79,4 +79,4 @@ jobs: env: AWS_REGION: "us-east-1" # or https://github.com/aws/aws-cli/issues/5623 AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} \ No newline at end of file + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 7d1a150f97619b5411ca0c919e97fa021ccd95fb Mon Sep 17 00:00:00 2001 From: Umberto Baldi <u.baldi@arduino.cc> Date: Tue, 6 Jul 2021 15:21:27 +0200 Subject: [PATCH 8/8] trigger workflow only on master --- .github/workflows/generate-index.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/generate-index.yml b/.github/workflows/generate-index.yml index 048416bd..16a2e224 100644 --- a/.github/workflows/generate-index.yml +++ b/.github/workflows/generate-index.yml @@ -4,6 +4,7 @@ name: Generate Index on: push: branches: + - master paths: - "generator/**" - "firmwares/**"