Skip to content
Open
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions .github/workflows/tests-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests main workflow

on:
workflow_call:
inputs:
snapd_branch:
required: true
type: string

jobs:
tests-main:
runs-on: self-hosted
env:
SNAP_BRANCH: ${{ inputs.snapd_branch }}
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: core-snap
path: "${{ github.workspace }}/core24.artifact"

- name: Run x86 tests
run: |
spread google-nested:tests/spread/main/

- name: Run arm64 tests
run: |
spread google-nested-arm:tests/spread/main/

- name: Discard spread workers
if: always()
run: |
shopt -s nullglob
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')"
done
71 changes: 71 additions & 0 deletions .github/workflows/tests-snapd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Tests snapd workflow

on:
workflow_call:
inputs:
snapd_branch:
required: true
type: string

jobs:
tests-snapd:
runs-on: ubuntu-latest
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"

- uses: actions/checkout@v2
with:
path: core-base
- uses: actions/checkout@v2
with:
repository: 'snapcore/snapd'
path: snapd
- uses: actions/download-artifact@v2
with:
name: core-snap

- name: Install spread
run: curl -s https://storage.googleapis.com/snapd-spread-tests/spread/spread-amd64.tar.gz | sudo tar xzv -C /usr/bin

- name: Build image
working-directory: '${{ github.workspace }}'
run: |
PROJECT_PATH=$PWD/core-base
# For os.query and others
PATH=$PATH:$PROJECT_PATH/tests/lib/external/snapd-testing-tools/tools/
. "core-base/tests/lib/prepare-utils.sh"

echo "************* INSTALLING DEPS *************"
install_base_deps

echo "************* DOWNLOADING SNAPS *************"
download_core24_snaps ${{ inputs.snapd_branch }}

echo "************* WRITING CLOUD-INIT CONFIG *************"
prepare_base_cloudinit

echo "************* BUILDING CORE24 IMAGE *************"
uc_snap="$(get_core_snap_name)"
mv core24.artifact "$uc_snap"
build_core24_image

echo "************* STARTING CORE24 VM *************"
start_snapd_core_vm '${{ github.workspace }}'

cd snapd

# add any test suites that should be tested here
SPREAD_EXTERNAL_ADDRESS=localhost:8022 spread external:ubuntu-core-24-64:tests/smoke/

- name: Discard spread workers
if: always()
run: |
shopt -s nullglob
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')"
done

105 changes: 18 additions & 87 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,95 +46,26 @@ jobs:
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')"
done

tests-main:
runs-on: self-hosted
tests-main-stable:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! Looks nice, alternative idea for future times, is that you could use a test-matrix instead of defining identical targets where only a variable is changing:

See examples:
https://github.com/snapcore/core-testing-jobs/blob/main/.github/workflows/cdimage-nightly.yml

So you could do like this:


    strategy:
      fail-fast: false
      matrix:
        channel: [stable, edge]
    with:
      snapd_branch: ${{ matrix.channel }}

Even better, maybe you could even define the templates as as matrix variable, but I'm not sure that github would accept that, as I don't know the order of evaluation when the workflow is passed (it was a hell with azure actions).


    strategy:
      fail-fast: false
      matrix:
        workflow: [tests-main.yml, tests-snapd.yml]
        channel: [stable, edge]
    uses: ./.github/workflows/${{ matrix.workflow }}
    with:
      snapd_branch: ${{ matrix.channel }}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works, yes. We should do that in another PR. I am not totally yet convince we require a matrix here.

needs: build
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: core-snap
path: "${{ github.workspace }}/core24.artifact"

- name: Run x86 tests
run: |
spread google-nested:tests/spread/main/
uses: ./.github/workflows/tests-main.yml
with:
snapd_branch: stable

- name: Run arm64 tests
run: |
spread-arm google-nested-arm:tests/spread/main/

- name: Discard spread workers
if: always()
run: |
shopt -s nullglob
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')"
done
tests-snapd:
runs-on: ubuntu-latest
tests-main-edge:
needs: build
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"

- uses: actions/checkout@v2
with:
path: core-base
- uses: actions/checkout@v2
with:
repository: 'snapcore/snapd'
path: snapd
- uses: actions/download-artifact@v2
with:
name: core-snap

- name: Install spread
run: curl -s https://storage.googleapis.com/snapd-spread-tests/spread/spread-amd64.tar.gz | sudo tar xzv -C /usr/bin

- name: Build image
working-directory: '${{ github.workspace }}'
run: |
PROJECT_PATH=$PWD/core-base
# For os.query and others
PATH=$PATH:$PROJECT_PATH/tests/lib/external/snapd-testing-tools/tools/
. "core-base/tests/lib/prepare-utils.sh"

echo "************* INSTALLING DEPS *************"
install_base_deps

echo "************* DOWNLOADING SNAPS *************"
download_core24_snaps 'edge'

echo "************* WRITING CLOUD-INIT CONFIG *************"
prepare_base_cloudinit
uses: ./.github/workflows/tests-main.yml
with:
snapd_branch: edge

echo "************* BUILDING CORE24 IMAGE *************"
uc_snap="$(get_core_snap_name)"
mv core24.artifact "$uc_snap"
build_base_image

echo "************* STARTING CORE24 VM *************"
start_snapd_core_vm '${{ github.workspace }}'

cd snapd

# add any test suites that should be tested here
SPREAD_EXTERNAL_ADDRESS=localhost:8022 spread external:ubuntu-core-24-64:tests/smoke/

- name: Discard spread workers
if: always()
run: |
shopt -s nullglob
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')"
done
tests-snapd-stable:
needs: build
uses: ./.github/workflows/tests-snapd.yml
with:
snapd_branch: stable

tests-snapd-edge:
needs: build
uses: ./.github/workflows/tests-snapd.yml
with:
snapd_branch: edge
2 changes: 1 addition & 1 deletion spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environment:
PROJECT_PATH: $SETUPDIR
PATH: $PATH:$PROJECT_PATH/tests/bin:$PROJECT_PATH/tests/lib/external/snapd-testing-tools/tools/
TESTSLIB: $PROJECT_PATH/tests/lib
SNAP_BRANCH: "edge" # stable/edge/beta
SNAP_BRANCH: '$(HOST: echo "${SNAP_BRANCH:-stable}")'
UC_VERSION: 24
# TODO: are these vars needed still?
LANG: "C.UTF-8"
Expand Down