Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(spread): add reusable workflow for Spread tests #280

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/spread.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Spread
run-name: Spread for ${{ github.ref }}

on:
workflow_call:

jobs:
spread-tests:
name: Run Spread tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Check changed paths
id: changed-slices
uses: dorny/paths-filter@v3
with:
filters: |
slices:
- added|modified: 'slices/**/*.yaml'
list-files: shell

- name: Check changed test directories
uses: tj-actions/changed-files@v35
rebornplusplus marked this conversation as resolved.
Show resolved Hide resolved
id: changed-tests
with:
separator: " "
dir_names: "true"
files: |
tests/spread/integration/**

- uses: actions/checkout@v4
with:
repository: snapcore/spread
path: _spread

- uses: actions/setup-go@v3
with:
go-version: '>=1.17.0'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Prepare Spread suites
id: spread-suites
env:
integration-tests: "tests/spread/integration"
run: |
set -ex
spread_tasks=""
for file in ${{ steps.changed-slices.outputs.slices_files }} ${{ steps.changed-tests.outputs.all_changed_files }}
do
pkg_name=$(basename $file | sed 's/\.yaml//g')
pkg_tests="${{ env.integration-tests }}/${pkg_name}"
if [ -f "${pkg_tests}/task.yaml" ] && [[ $spread_tasks != *"${pkg_tests}"* ]]
then
spread_tasks="${spread_tasks} ${pkg_tests}"
fi
done

echo "run-tasks=$(echo ${spread_tasks} | awk '{$1=$1};1')" >> $GITHUB_OUTPUT

- name: Build and run spread
run: |
(cd _spread/cmd/spread && go build)
_spread/cmd/spread/spread -v ${{ steps.spread-suites.outputs.run-tasks }}
Loading