-
Notifications
You must be signed in to change notification settings - Fork 604
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
tests: add feature tagging workflow #15148
Open
maykathm
wants to merge
7
commits into
canonical:master
Choose a base branch
from
maykathm:SNAPDENG-34441-add-feature-tagging-workflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1471393
tests: add feature-tagging workflow
maykathm 45ccafc
tests: add workflow rerun in case of failure
maykathm feef96e
tests: add feature-tag consolidation if spread task has been rerun
maykathm 44ba42a
tests: added feature tagging on master pushes of only changed tests
maykathm 0fe129b
tests: addressed review comments and changed tests name format from u…
maykathm 75369e9
github: added option to force the use of the rules file
maykathm 49a5046
tests: create structures for features
maykathm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
name: Feature Tagging | ||
|
||
on: | ||
push: | ||
branches: ["master"] | ||
|
||
workflow_dispatch: | ||
inputs: | ||
features: | ||
type: string | ||
description: 'Comma-separated list of features to tag' | ||
default: 'all' | ||
maximum-reruns: | ||
type: number | ||
description: 'Maximum number of times to rerun failed spread tasks upon failure' | ||
default: 3 | ||
run-all: | ||
type: boolean | ||
description: 'If true, will run all spread tests. If false, will only run tagging on changed spread tests in the last commit' | ||
default: false | ||
|
||
jobs: | ||
set-inputs: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
features: ${{ steps.step1.outputs.features }} | ||
maximum-reruns: ${{ steps.step1.outputs.maximum-reruns }} | ||
run-all: ${{ steps.step1.outputs.run-all }} | ||
steps: | ||
- name: Set inputs | ||
run: | | ||
echo "features=${{ inputs.features || 'all' }}" >> $GITHUB_OUTPUT | ||
echo "maximum-reruns=${{ inputs.maximum-reruns || 3 }}" >> $GITHUB_OUTPUT | ||
echo "run-all=${{ inputs.run-all || false }}" >> $GITHUB_OUTPUT | ||
|
||
read-systems: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
fundamental-systems: ${{ steps.read-systems.outputs.fundamental-systems }} | ||
non-fundamental-systems: ${{ steps.read-systems.outputs.non-fundamental-systems }} | ||
nested-systems: ${{ steps.read-systems.outputs.nested-systems }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Read matrix file | ||
id: read-systems | ||
shell: bash | ||
run: | | ||
echo "fundamental-systems=$(jq -c . ./.github/workflows/fundamental-systems.json)" >> $GITHUB_OUTPUT | ||
echo "non-fundamental-systems=$(jq -c . ./.github/workflows/non-fundamental-systems.json)" >> $GITHUB_OUTPUT | ||
echo "nested-systems=$(jq -c . ./.github/workflows/nested-systems.json)" >> $GITHUB_OUTPUT | ||
|
||
tag-features-fundamental: | ||
uses: ./.github/workflows/spread-tests.yaml | ||
needs: [set-inputs, read-systems] | ||
name: "spread ${{ matrix.group }}" | ||
with: | ||
runs-on: '["self-hosted", "spread-enabled"]' | ||
group: ${{ matrix.group }} | ||
backend: ${{ matrix.backend }} | ||
systems: ${{ matrix.systems }} | ||
tasks: ${{ matrix.tasks }} | ||
rules: ${{ fromJSON(needs.set-inputs.outputs.run-all) && matrix.rules || 'feature-tagging.yaml' }} | ||
is-fundamental: true | ||
use-snapd-snap-from-master: true | ||
spread-tag-features: ${{ needs.set-inputs.outputs.features }} | ||
force-use-ruleset: ${{ ! fromJSON(needs.set-inputs.outputs.run-all) }} | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.read-systems.outputs.fundamental-systems) }} | ||
|
||
tag-features-non-fundamental: | ||
uses: ./.github/workflows/spread-tests.yaml | ||
needs: [set-inputs, read-systems] | ||
name: "spread ${{ matrix.group }}" | ||
with: | ||
runs-on: '["self-hosted", "spread-enabled"]' | ||
group: ${{ matrix.group }} | ||
backend: ${{ matrix.backend }} | ||
systems: ${{ matrix.systems }} | ||
tasks: ${{ matrix.tasks }} | ||
rules: ${{ fromJSON(needs.set-inputs.outputs.run-all) && matrix.rules || 'feature-tagging.yaml' }} | ||
use-snapd-snap-from-master: true | ||
spread-tag-features: ${{ needs.set-inputs.outputs.features }} | ||
force-use-ruleset: ${{ ! fromJSON(needs.set-inputs.outputs.run-all) }} | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.read-systems.outputs.non-fundamental-systems) }} | ||
|
||
tag-features-nested: | ||
uses: ./.github/workflows/spread-tests.yaml | ||
needs: [set-inputs, read-systems] | ||
name: "spread ${{ matrix.group }}" | ||
with: | ||
runs-on: '["self-hosted", "spread-enabled"]' | ||
group: ${{ matrix.group }} | ||
backend: ${{ matrix.backend }} | ||
systems: ${{ matrix.systems }} | ||
tasks: ${{ matrix.tasks }} | ||
rules: ${{ fromJSON(needs.set-inputs.outputs.run-all) && matrix.rules || 'feature-tagging.yaml' }} | ||
use-snapd-snap-from-master: true | ||
spread-tag-features: ${{ needs.set-inputs.outputs.features }} | ||
force-use-ruleset: ${{ ! fromJSON(needs.set-inputs.outputs.run-all) }} | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.read-systems.outputs.nested-systems) }} | ||
|
||
re-run: | ||
permissions: | ||
actions: write | ||
needs: [set-inputs, tag-features-fundamental, tag-features-non-fundamental, tag-features-nested] | ||
# If the spread tests ended in failure, rerun the workflow up to maximum-reruns-1 times | ||
if: failure() && fromJSON(github.run_attempt) < fromJSON(needs.set-inputs.outputs.maximum-reruns) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- env: | ||
GH_REPO: ${{ github.repository }} | ||
GH_TOKEN: ${{ github.token }} | ||
run: gh workflow run rerun.yaml -F run_id=${{ github.run_id }} | ||
|
||
create-reports: | ||
needs: [set-inputs, tag-features-fundamental, tag-features-non-fundamental, tag-features-nested] | ||
runs-on: ubuntu-latest | ||
if: success() || fromJSON(github.run_attempt) >= fromJSON(needs.set-inputs.outputs.maximum-reruns) | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get generated data | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
let page = 1; | ||
let per_page = 100; | ||
let allArtifacts = []; | ||
let response; | ||
do { | ||
response = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: context.runId, | ||
per_page: per_page, | ||
page: page | ||
}); | ||
allArtifacts = allArtifacts.concat(response.data.artifacts); | ||
page++; | ||
} while (response.data.artifacts.length === per_page); | ||
|
||
let matchingArtifacts = allArtifacts.filter((artifact) => { | ||
return artifact.name.startsWith(`feature-tags`); | ||
}); | ||
|
||
for (let artifact of matchingArtifacts) { | ||
let download = await github.rest.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: artifact.id, | ||
archive_format: 'zip', | ||
}); | ||
let fs = require('fs'); | ||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifact.name}.zip`, Buffer.from(download.data)); | ||
console.log(`Downloaded artifact: ${artifact.name}.zip`); | ||
} | ||
- name: Unzip artifacts | ||
run: | | ||
mkdir -p feature-tags-artifacts | ||
find . -name "feature-tags*.zip" | while read filename; do | ||
unzip "$filename" -d "feature-tags-artifacts" | ||
done | ||
|
||
- name: Consolidate feature data | ||
run: | | ||
./tests/lib/compose-features.py \ | ||
--dir "feature-tags-artifacts" \ | ||
--output "final-feature-tags" \ | ||
--replace-old-runs | ||
|
||
- name: Upload feature data | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "feature-tags" | ||
path: "final-feature-tags" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
run_id: | ||
required: true | ||
jobs: | ||
rerun: | ||
permissions: | ||
actions: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: rerun ${{ inputs.run_id }} | ||
env: | ||
GH_REPO: ${{ github.repository }} | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh run watch ${{ inputs.run_id }} > /dev/null 2>&1 | ||
gh run rerun ${{ inputs.run_id }} --failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, can we use a temp dir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this would be for personal use, I thought tmp would be the best option.