Skip to content

Commit

Permalink
Merge pull request #6 from pguyot/tests
Browse files Browse the repository at this point in the history
Add tests as workflows for this action
  • Loading branch information
pguyot authored Jun 27, 2021
2 parents 663c012 + a80e9ba commit 8542916
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test-armv7l.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test cpu option
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pguyot/arm-runner-action@HEAD
with:
cpu: cortex-a8
commands: |
echo "Minimal"
test `uname -m` = 'armv7l'
15 changes: 15 additions & 0 deletions .github/workflows/test-artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test artifact copy
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pguyot/arm-runner-action@HEAD
with:
copy_artifact_path: artifact
commands: |
touch artifact
- name: Test artifact was copied
run: |
test -f artifact
12 changes: 12 additions & 0 deletions .github/workflows/test-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test minimal configuration
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pguyot/arm-runner-action@HEAD
with:
commands: |
echo "Minimal"
test `uname -m` = 'armv6l'
52 changes: 52 additions & 0 deletions .github/workflows/test-optimize_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test optimize_image
on: [push, pull_request]
jobs:
optimized:
runs-on: ubuntu-latest
outputs:
imgsize: ${{ steps.compress.outputs.imgsize }}
steps:
- uses: actions/checkout@v2
- uses: pguyot/arm-runner-action@HEAD
id: optimized
with:
base_image: raspios_lite:2021-05-07
optimize_image: yes
commands: |
cat /dev/random > /rand || rm /rand
- name: Compress image
id: compress
run: |
mv ${{ steps.optimized.outputs.image }} /home/actions/temp/optimized-image.img
gzip /home/actions/temp/optimized-image.img
imgsize=`stat --printf="%s" /home/actions/temp/optimized-image.img.gz`
echo "::set-output name=imgsize::${imgsize}"
unoptimized:
runs-on: ubuntu-latest
outputs:
imgsize: ${{ steps.compress.outputs.imgsize }}
steps:
- uses: actions/checkout@v2
- uses: pguyot/arm-runner-action@HEAD
id: unoptimized
with:
base_image: raspios_lite:2021-05-07
optimize_image: no
commands: |
cat /dev/random > /rand || rm /rand
- name: Compress image
id: compress
run: |
mv ${{ steps.unoptimized.outputs.image }} /home/actions/temp/unoptimized-image.img
gzip /home/actions/temp/unoptimized-image.img
imgsize=`stat --printf="%s" /home/actions/temp/unoptimized-image.img.gz`
echo "::set-output name=imgsize::${imgsize}"
compare:
runs-on: ubuntu-latest
needs: [optimized, unoptimized]
steps:
- name: Test image sizes
run: |
echo "Optimized size: ${{needs.optimized.outputs.imgsize}}"
echo "Unoptimized size: ${{needs.unoptimized.outputs.imgsize}}"
test $(( ${{needs.unoptimized.outputs.imgsize}} - ${{needs.optimized.outputs.imgsize}} )) > 300000000
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Minimal usage is as follows:
- uses: actions/checkout@v2
- uses: pguyot/arm-runner-action@v1
with:
optimize_image: no
commands: |
commands to run tests

Expand Down Expand Up @@ -49,6 +48,8 @@ Typical usage to upload an image as an artifact:
name: Release image
path: my-release-image.img.xz

Several scenarios are actually implemented as [tests](/.github/workflows).

### Commands

The repository is copied to the image before the commands script is executed
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ inputs:
copy_artifact_dest:
description: 'Where to copy artifacts'
required: false
defaut: '.'
default: '.'
copy_repository_path:
description: 'Where to copy repository path'
required: false
default: ''
optimize_image:
description: 'Zero-fill unused filesystem blocks during final cleanup'
required: false
defaut: 'yes'
default: 'yes'
use_systemd_nspawn:
description: 'Use systemd-nspawn instead of chroot'
required: false
defaut: 'no'
default: 'no'
outputs:
image:
description: "Path to image"
Expand Down

0 comments on commit 8542916

Please sign in to comment.