Skip to content

Commit

Permalink
Updates per new docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy4495 committed Sep 19, 2023
1 parent c74cdf6 commit 0fd9d4c
Showing 1 changed file with 27 additions and 39 deletions.
66 changes: 27 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ For [triggering builds][28] on multiple repos which are dependent on a library:
I have several template workflows available in my [.github repository][12]:
- [compile-sketches][13]
- Arduino `compile-sketches` workflow with matrix build definitions for various hardware platforms.
- [arduino-compile-sketches][13]
- Arduino [`compile-sketches`][8] workflow with matrix build definitions for various hardware platforms.
- Update the matrix list as needed for the repo being compiled.
- [markdown-link-check][14]
- Checks for dead links in Markdown files. Automatically runs once a month.
Expand All @@ -95,61 +95,49 @@ I have several template workflows available in my [.github repository][12]:

## The `act` Tool for Testing Workflows Locally

[`act`][1] uses [Docker][5] with customized [images][6] to create a local environment similar to the environment used by GitHub Actions. The default `act` image is intentionally [incomplete][7] to keep its size manageable. While it works well for many actions, there are cases which require extra workflow steps to set up the environment in order to get the action to run locally.
[`act`][1] uses [Docker][5] with customized [images][6] to create a local environment similar to the environment used by GitHub Actions. The default `act` image is intentionally [incomplete][7] to keep its size manageable. While it works well for many actions, there are issues that arise since the environments are not quite the same.

### Arduino `compile-sketches` Action
### `arduino-compile-sketches` Action

The main problem that I have run into with `act` is when using Arduino's [`compile-sketches`][8] action. Release [v1.1.0 of the `compile-sketches` action][10] changed the Python and related tools configuration to make the action incompatible with the default `act` image ([`catthehacker/ubuntu:act-latest`][9]).
One problem occurs when using Arduino's [`compile-sketches`][8] action. Release [v1.1.0 of the `compile-sketches` action][10] changed the Python and related tools configuration to make the action incompatible with the default `act` image ([`catthehacker/ubuntu:act-latest`][9]).

In particular, the following error will be thrown when trying to use `compile-sketches` v1.1.0 and the `ubuntu:act-latest` image:
In particular, the following messages will be appear in the `act` output when trying to use `compile-sketches` v1.1.0 and the `ubuntu:act-latest` image, and the job will fail:

``` text
/var/run/act/workflow/1-composite-2.sh: line 5: pipx: command not found
Failure - Main Action setup
Job failed
```

In addition, a change in cpython [v3.11.5][22] created another [issue][23] which causes the error:

```text
ImportError: /opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/lib-dynload/math.cpython-311-x86_64-linux-gnu.so: undefined symbol: _PyModule_Add
| installing poetry from spec 'poetry==1.4.0'...
| ⚠️ File exists at
| /root/.local/bin/poetry and points
| to /root/.local/venv/bin/poetry,
| not /root/.local/pipx/venvs/poetry
| /bin/poetry. Not modifying.
| installed package poetry 1.4.0, installed using Python 3.11.2
| - poetry (symlink missing or pointing to unexpected location)
| done! ✨ 🌟 ✨
```

#### Fixing the `compile-sketches` Errors

To fix these problems, `python`, `poetry`, and `pipx` need to be installed locally into the `act` Docker image. It is also necessary to make sure that the version of python installed for `act` compatibility is the same version installed by the `arduino-compile-sketches` action.

To get the `compile-sketches` action to run locally, update your workflow as follows:
To fix this problems, `/root/.local/bin` needs to be added to the shell's PATH so that the `poetry` executable can be found:

```yaml
steps: # Existing code
- uses: actions/checkout@main # Existing code
# *** Add the code below ***
- name: Clone compile-sketches to get python version (using nektos/act locally)
- name: Update PATH if using nektos/act locally
if: ${{ env.ACT }}
run: cd /tmp; git clone 'https://github.com/arduino/compile-sketches'
- name: setup-python (using nektos/act locally)
if: ${{ env.ACT }}
uses: actions/setup-python@v4
with:
python-version-file: /tmp/compile-sketches/.python-version
- name: Install Poetry (using nektos/act locally)
if: ${{ env.ACT }}
uses: snok/install-poetry@v1
- name: Install pipx (using nektos/act locally)
if: ${{ env.ACT }}
run: pip install pipx
# *** Add the code above ***
- uses: arduino/compile-sketches@v1 # Existing code
run: |
echo "/root/.local/bin" >> $GITHUB_PATH
```

While the workflow could be configured to install these tools regardless of whether the action is running on GitHub or locally using `act`, I prefer to install the tools only when running locally. This is done by checking for the environment variable [`env.ACT`][11] before running an installation step.
By checking for the environment variable [`env.ACT`][11] first, the PATH update step is only run when using `act`.

Note that versions of the `ubuntu:act-latest` image published before 18-Sep-2023 have additional issues, but the latest published version only requires the above change (see [61][61-images] and [74][74]).

### Other Errors
### Timeout and Rate-limiting Errors

I occasionally run into timeout and rate-limiting errors when running `act` that aren't specific to the actions themselves. These errors can generally be cleared by waiting a few minutes and then re-running the action.
When using `act`, I occasionally run into timeout and rate-limiting errors that aren't specific to the actions themselves. These errors can generally be cleared by waiting a few minutes and then re-running the action.

Examples of timeout and rate-limiting errors:
Examples of the errors:

```text
Downloading index: package_index.tar.bz2 Get "https://downloads.arduino.cc/packages/package_index.tar.bz2": dial tcp: lookup downloads.arduino.cc on 192.168.1.1:53: read udp 192.168.1.1:33527->192.168.1.1:53: i/o timeout
Expand Down Expand Up @@ -260,8 +248,6 @@ The software and other files in this repository are released under what is commo
[19]: https://github.com/marketplace/actions/arduino-arduino-lint-action
[20]: https://github.com/marketplace/actions/markdownlint-cli
[21]: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
[22]: https://github.com/python/cpython/releases/tag/v3.11.5
[23]: https://github.com/python/cpython/issues/108525
[24]: https://docs.github.com/en/actions/using-workflows/reusing-workflows
[25]: #fixing-the-compile-sketches-errors
[26]: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
Expand All @@ -272,6 +258,8 @@ The software and other files in this repository are released under what is commo
[47]: https://github.com/github/vscode-github-actions/issues/47
[61]: https://github.com/github/vscode-github-actions/issues/61
[67]: https://github.com/github/vscode-github-actions/issues/67
[61-images]: https://github.com/catthehacker/docker_images/issues/61
[74]: https://github.com/catthehacker/docker_images/pull/74
[1287]: https://github.com/nektos/act/issues/1287
[1785]: https://github.com/nektos/act/issues/1785
[1912]: https://github.com/nektos/act/pull/1912
Expand Down

0 comments on commit 0fd9d4c

Please sign in to comment.