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

dynamically discover smoke tests #8551

Merged
merged 5 commits into from
Dec 6, 2023
Merged
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
82 changes: 1 addition & 81 deletions .github/smoke-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
"test": "bundler",
"ecosystem": "bundler"
},
{
"core": "bundler",
"test": "bundler-group-rules",
"ecosystem": "bundler"
},
{
"core": "bundler",
"test": "bundler-group-vendoring",
"ecosystem": "bundler"
},
{
"core": "cargo",
"test": "cargo",
Expand Down Expand Up @@ -49,36 +39,11 @@
"test": "go",
"ecosystem": "gomod"
},
{
"core": "go_modules",
"test": "go-close-pr",
"ecosystem": "gomod"
},
{
"core": "go_modules",
"test": "go-group-rules",
"ecosystem": "gomod"
},
{
"core": "go_modules",
"test": "go-security",
"ecosystem": "gomod"
},
{
"core": "go_modules",
"test": "go-update-pr",
"ecosystem": "gomod"
},
{
"core": "gradle",
"test": "gradle",
"ecosystem": "gradle"
},
{
"core": "gradle",
"test": "gradle-version-catalog",
"ecosystem": "gradle"
},
{
"core": "hex",
"test": "hex",
Expand All @@ -94,36 +59,6 @@
"test": "npm",
"ecosystem": "npm"
},
{
"core": "npm_and_yarn",
"test": "npm-group-rules",
"ecosystem": "npm"
},
{
"core": "npm_and_yarn",
"test": "npm-remove-transitive",
"ecosystem": "npm"
},
{
"core": "npm_and_yarn",
"test": "pnpm",
"ecosystem": "npm"
},
{
"core": "npm_and_yarn",
"test": "yarn",
"ecosystem": "npm"
},
{
"core": "npm_and_yarn",
"test": "yarn-berry",
"ecosystem": "npm"
},
{
"core": "npm_and_yarn",
"test": "yarn-berry-workspaces",
"ecosystem": "npm"
},
{
"core": "nuget",
"test": "nuget",
Expand All @@ -141,22 +76,7 @@
},
{
"core": "python",
"test": "pip",
"ecosystem": "pip"
},
{
"core": "python",
"test": "pipenv",
"ecosystem": "pip"
},
{
"core": "python",
"test": "pip-compile",
"ecosystem": "pip"
},
{
"core": "python",
"test": "poetry",
"test": "python",
"ecosystem": "pip"
},
{
Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,19 @@ jobs:
jq -c --argjson changes "$(cat changes.json)" '[.[] | select(.core as $p | $changes | index($p))]' .github/smoke-matrix.json > filtered.json
cat filtered.json

# Curl the smoke-test tests directory to get a list of tests to run
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

URL=https://api.github.com/repos/dependabot/smoke-tests/contents/tests
curl $URL > tests.json

# Select the names that match smoke-$test*.yaml, where $test is the .text value from filtered.json
# We end up with, for example: [{core: "bundler", ecosystem: "rubygems", name: "smoke-bundler.yaml"}]
jq -c '.[]' filtered.json | while read -r i; do
test=$(echo "$i" | jq -r '.test')
jq --argjson i "$i" --arg test "-$test" -r '.[] | select(.name | contains($test)) | {core: ($i | .core), ecosystem: ($i | .ecosystem), name: .name}' tests.json
done | jq -cs . > suites.json

# Set the step output
echo "suites=$(cat filtered.json)" >> $GITHUB_OUTPUT
echo "suites=$(cat suites.json)" >> $GITHUB_OUTPUT
e2e:
needs: discover
runs-on: ubuntu-latest
Expand All @@ -62,14 +73,21 @@ jobs:
gh release download --repo dependabot/cli -p "*linux-amd64.tar.gz"
tar xzvf *.tar.gz >/dev/null 2>&1
./dependabot --version
URL=https://api.github.com/repos/dependabot/smoke-tests/contents/tests/smoke-${{ matrix.suite.test }}.yaml
URL=https://api.github.com/repos/dependabot/smoke-tests/contents/tests/${{ matrix.suite.name }}
curl $(gh api $URL --jq .download_url) -o smoke.yaml

# Download the Proxy cache. The job is ideally 100% cached so no real calls are made.
# Allowed to fail to get out of checking and egg situations, for example, when adding a new ecosystem.
- name: Download cache
run: |
gh run download --repo dependabot/smoke-tests --name cache-${{ matrix.suite.test }} --dir cache
# The name of the cache is derived from the test name, e.g. smoke-bundler.yaml -> cache-bundler
TEST=${{ matrix.suite.name }}
# Remove the smoke- and the .yaml or .yml suffix
CACHE=${TEST#smoke-}
CACHE=${CACHE%.yaml}
CACHE=${CACHE%.yml}

gh run download --repo dependabot/smoke-tests --name cache-$CACHE --dir cache
continue-on-error: true

- name: Build ecosystem image
Expand Down