Skip to content

Commit

Permalink
Use git ref for tagging releases (#19)
Browse files Browse the repository at this point in the history
This patch:
- adds support for tagged releases to improve backwards compatibility and reduce breakage for users of this action
- renames the `build_and_test` workflow to `release`
- adds a warning to the `README` that this action is still very much in flux

Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
  • Loading branch information
kbieganski authored Apr 24, 2023
1 parent 91ea74b commit 77d4aa2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and test
name: Release
on: [push, workflow_dispatch, repository_dispatch]

permissions: write-all
Expand All @@ -9,17 +9,32 @@ jobs:
permissions:
pull-requests: read
outputs:
build: ${{ steps.filter.outputs.build }}
build: ${{ steps.build-needed.outputs.build }}
steps:
- uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref }}
base: ${{ github.ref_name }}
filters: |
build:
- 'br2-external/**'
- name: check if release exists
id: check-release
run: |
# gh release view returns non-zero if no such release exists
echo "build=$(gh release view ${{ github.ref_name }} &> /dev/null && echo $? || echo $?)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: check if build is needed
id: build-needed
run: |
# Step outputs apparently are strings, so we have to compare against literals to avoid silly JS type coercion issues.
echo "build=${{ steps.filter.outputs.build == 'true' || steps.check-release.outputs.build != '0' }}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: changes
Expand All @@ -41,7 +56,7 @@ jobs:
repo_token: "${{ github.token }}"
file: images.tar.xz
asset_name: images.tar.xz
tag: latest
tag: ${{ github.ref_name }}
overwrite: true

default-configuration-test:
Expand All @@ -61,7 +76,6 @@ jobs:
uses: ./
with:
shared-dir: ./tests
image: https://github.com/${{ github.repository }}/releases/download/latest/images.tar.xz
renode-run: |
wget example.org
gpiodetect
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# renode-linux-runner-action

Copyright (c) 2022 [Antmicro](https://www.antmicro.com)
Copyright (c) 2022-2023 [Antmicro](https://www.antmicro.com)

renode-linux-runner-action is a GitHub Action that can run scripts on Linux inside the Renode emulation.

> **Warning**
> This action is under heavy development. We will do our best to avoid breaking
> changes, but we cannot guarantee full backwards compatibility at this point.
> We recommend using the `v0` tag to minimize chances of breakage. If your
> workflow fails due to our changes, feel free to file an issue.
## Emulated system

The emulated system is based on the [Buildroot 2022.11.3](https://github.com/buildroot/buildroot/tree/2022.11.3) and it runs on the RISC-V/HiFive Unleashed platform in [Renode 1.13.3](https://github.com/renode/renode).
Expand All @@ -27,7 +33,7 @@ It contains the Linux kernel configured with some emulated devices enabled and i
### Devices syntax

```yaml
- uses: antmicro/renode-linux-runner-action@main
- uses: antmicro/renode-linux-runner-action@v0
with:
devices: |
device1 param1 param2 param3 ...
Expand All @@ -49,7 +55,7 @@ It contains the Linux kernel configured with some emulated devices enabled and i
Running a single command using the `renode-run` parameter:

```yaml
- uses: antmicro/renode-linux-runner-action@main
- uses: antmicro/renode-linux-runner-action@v0
with:
shared-dir: ./shared-dir
renode-run: command_to_run
Expand All @@ -59,7 +65,7 @@ Running a single command using the `renode-run` parameter:
Running multiple commands works the same way as the standard `run` command:

```yaml
- uses: antmicro/renode-linux-runner-action@main
- uses: antmicro/renode-linux-runner-action@v0
with:
shared-dir: ./shared-dir
renode-run: |
Expand All @@ -72,4 +78,4 @@ Running multiple commands works the same way as the standard `run` command:

Multiple devices can also be specified this way.

The [renode-linux-runner-test](.github/workflows/build_and_test.yml) workflow contains an example usage of this action.
The [release](.github/workflows/release.yml) workflow contains an example usage of this action.
22 changes: 15 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
image:
description: Compiled linux image source
required: false
default: "https://github.com/antmicro/renode-linux-runner-action/releases/download/latest/images.tar.xz"
default: ""
python-packages:
description: Custom python packages that will be added to your shared dir
required: false
Expand All @@ -35,14 +35,22 @@ runs:

- id: get-images
run: |
if [ -f "${{ inputs.image }}" ] && [ $(realpath "${{ inputs.image }}") == "$(realpath ${{github.action_path}}/images.tar.xz)" ]; then \
echo File already exists; \
elif [ -f "${{ inputs.image }}" ]; then \
cp "${{ inputs.image }}" ${{github.action_path}}/images.tar.xz; \
else \
wget -q --no-verbose "${{ inputs.image }}" -O ${{github.action_path}}/images.tar.xz; \
if [ -z "$IMAGE" ]; then
IMAGE="https://github.com/$ACTION_REPO/releases/download/$ACTION_REF/images.tar.xz"
fi
if [ -f "$IMAGE" ] && [ $(realpath "$IMAGE") == "$(realpath ${{github.action_path}}/images.tar.xz)" ]; then
echo File already exists;
elif [ -f "$IMAGE" ]; then
cp "$IMAGE" ${{github.action_path}}/images.tar.xz;
else
wget -q --no-verbose "$IMAGE" -O ${{github.action_path}}/images.tar.xz;
fi
shell: bash
env:
IMAGE: ${{ inputs.image }}
# https://github.com/orgs/community/discussions/49245
ACTION_REPO: ${{ github.action_repository || github.repository }}
ACTION_REF: ${{ github.action_ref || github.ref_name }}

- id: decompress
run: cd ${{github.action_path}} && tar xf images.tar.xz
Expand Down
2 changes: 1 addition & 1 deletion br2-external/external.desc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name: SIFIVE_RENODE_CI
desc: Linux embedded instance for use in github actions
desc: Linux embedded instance for use in github actions

0 comments on commit 77d4aa2

Please sign in to comment.