Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bcb6367
Add `init-package.sh` script
Drarig29 Jan 15, 2026
3a0e179
Adapt `migrate.sh` script
Drarig29 Jan 15, 2026
af0ad1d
Fix lint-packages script
Drarig29 Jan 15, 2026
ef19812
Add docs about listing packages
Drarig29 Jan 15, 2026
0f96c7e
Check published packages in CI
Drarig29 Jan 15, 2026
59955fe
Init `junit` plugin
Drarig29 Jan 15, 2026
1b58d6f
Colorize scripts
Drarig29 Jan 15, 2026
b5b1f58
Reintroduce `--provenance`
Drarig29 Jan 15, 2026
0d10074
Publish junit `0.0.3` with `--provenance`
Drarig29 Jan 15, 2026
4880c9c
Delete temporary workflow
Drarig29 Jan 15, 2026
d91da28
Run migrate script
Drarig29 Jan 15, 2026
f77411e
Split `JunitUploadCommand`
Drarig29 Jan 15, 2026
67e4e19
Run `yarn lint:packages --fix`
Drarig29 Jan 15, 2026
918c36f
Fix tests
Drarig29 Jan 15, 2026
d02698b
Run `yarn lint:packages --fix` again
Drarig29 Jan 15, 2026
ea53ee5
Change version at the end of init script
Drarig29 Jan 15, 2026
aefdd28
Fail CI on PRs with empty initialized packages
Drarig29 Jan 15, 2026
cb9e936
Merge branch 'corentin.girard/SYNTH-21709/migrate-junit' into corenti…
Drarig29 Jan 15, 2026
251d8d4
Rename `init-package.sh` to `create-package.sh`
Drarig29 Jan 19, 2026
9c59805
Add `package:create` and `package:migrate` aliases
Drarig29 Jan 19, 2026
4b54a3a
Reduce the role of `create-package.sh`
Drarig29 Jan 19, 2026
b3158ff
Make new script to check NPM packages
Drarig29 Jan 19, 2026
c2adc0d
Merge branch 'master' into corentin.girard/SYNTH-23939/init-plugin
Drarig29 Jan 19, 2026
1dfd4e4
Undo ci.yml changes
Drarig29 Jan 19, 2026
ada3efa
Change publish-release.yml instead
Drarig29 Jan 19, 2026
7ad9a71
Stricter regex for tag
Drarig29 Jan 19, 2026
1256623
Still run `yarn install` in create package script
Drarig29 Jan 19, 2026
573c719
Rename scripts
Drarig29 Jan 19, 2026
48d387f
Update naming
Drarig29 Jan 19, 2026
af78369
Extract PR author and ping them
Drarig29 Jan 19, 2026
55cc372
Remove temporary fail safe
Drarig29 Jan 19, 2026
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
45 changes: 32 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ jobs:
yarn add @datadog/datadog-api-client
yarn node bin/check-junit-upload.js
env:
EXTRA_TEST_QUERY_FILTER: "@testmeasure1:20"
EXTRA_SESSION_QUERY_FILTER: "@sessionmeasure1:40"
EXTRA_TEST_QUERY_FILTER: '@testmeasure1:20'
EXTRA_SESSION_QUERY_FILTER: '@sessionmeasure1:40'
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
Expand All @@ -173,8 +173,8 @@ jobs:
yarn add @datadog/datadog-api-client
yarn node bin/check-junit-upload.js
env:
EXTRA_TEST_QUERY_FILTER: "@testmeasure2:60"
EXTRA_SESSION_QUERY_FILTER: "@sessionmeasure2:80"
EXTRA_TEST_QUERY_FILTER: '@testmeasure2:60'
EXTRA_SESSION_QUERY_FILTER: '@sessionmeasure2:80'
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
Expand Down Expand Up @@ -264,8 +264,8 @@ jobs:
yarn add @datadog/datadog-api-client
yarn node bin/check-junit-upload.js
env:
EXTRA_TEST_QUERY_FILTER: "@testmeasure1:20"
EXTRA_SESSION_QUERY_FILTER: "@sessionmeasure1:40"
EXTRA_TEST_QUERY_FILTER: '@testmeasure1:20'
EXTRA_SESSION_QUERY_FILTER: '@sessionmeasure1:40'
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
Expand All @@ -278,8 +278,8 @@ jobs:
yarn add @datadog/datadog-api-client
yarn node bin/check-junit-upload.js
env:
EXTRA_TEST_QUERY_FILTER: "@testmeasure2:60"
EXTRA_SESSION_QUERY_FILTER: "@sessionmeasure2:80"
EXTRA_TEST_QUERY_FILTER: '@testmeasure2:60'
EXTRA_SESSION_QUERY_FILTER: '@sessionmeasure2:80'
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
Expand Down Expand Up @@ -634,8 +634,8 @@ jobs:
cpu_count: 2
diff_aware: false

check-licenses:
name: Check licenses
additional-checks:
name: Additional checks
runs-on: ubuntu-latest

steps:
Expand All @@ -644,7 +644,26 @@ jobs:
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 22.19.0
# The install step has been added here such that the `.yarn/install-state.gz` file is generated. This file is used
# by the script `check-licenses` below.
- run: yarn install --immutable
- run: yarn check-licenses
- name: Check licenses
run: yarn check-licenses
- name: Check published packages
run: |
Comment thread
Drarig29 marked this conversation as resolved.
Outdated
local=$(yarn workspaces list --json --no-private | jq '.name' | sort)
remote=$(npm search 'maintainer:datadog keywords:datadog-ci' --json | jq '.[].name' | sort)

DIFF_OUTPUT=$(diff -u --label "Published packages (Actual)" --label "Local packages (Expected)" <(echo "$remote") <(echo "$local")) || true

if [ -z "$DIFF_OUTPUT" ]; then
echo "All local packages exist on NPM ✅"
exit 0
else
echo "$DIFF_OUTPUT"
echo "### Some local packages were not published to NPM yet ❌" >> $GITHUB_STEP_SUMMARY
echo '```diff' >> $GITHUB_STEP_SUMMARY
echo "$DIFF_OUTPUT" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
echo "**Please follow the instructions** at https://datadoghq.atlassian.net/wiki/x/QYDRaQE" >> $GITHUB_STEP_SUMMARY
exit 1
Comment thread
Drarig29 marked this conversation as resolved.
Outdated
fi
8 changes: 4 additions & 4 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- v* # Any version tag

permissions:
id-token: write # To publish on NPM with provenance and to federate tokens
id-token: write # For OIDC publishing with provenance and to federate tokens
contents: write # Required for the draft release

jobs:
Expand Down Expand Up @@ -258,11 +258,11 @@ jobs:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 24.11.1 # Version supporting OIDC
registry-url: "https://registry.npmjs.org"
node-version: '24' # Needed for OIDC publishing
registry-url: 'https://registry.npmjs.org'
Comment on lines +280 to +281
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

- run: yarn install --immutable
- run: yarn build
- run: yarn publish:all
- run: yarn publish:all --provenance
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reintroduced --provenance to get back the checkmark on NPM:

Image


bump-ci-integrations:
name: Bump datadog-ci in integration
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test publish package on NPM

on:
push:
branches: [corentin.girard/SYNTH-23939/init-plugin]

permissions:
id-token: write

jobs:
npm-publish:
runs-on: ubuntu-latest
environment: npm
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- run: yarn install --immutable
- run: yarn workspace @datadog/datadog-ci-plugin-junit npm publish --provenance
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
Pull requests for bug fixes are welcome, but before submitting new features or changes to current functionality, [open an issue](https://github.com/DataDog/datadog-ci/issues/new)
and discuss your ideas or propose the changes you wish to make. After a resolution is reached, a PR can be submitted for review.

### Listing NPM packages

This repository is a monorepo containing multiple packages published to NPM. You can list all packages with the following command:

```sh
npm search 'maintainer:datadog keywords:datadog-ci'
```

To only list the plugins:

```sh
npm search 'maintainer:datadog keywords:datadog-ci,plugin'
```

You can also use the following datadog-ci command to get more information:

```sh
yarn launch plugin list --all
```

### Running command in development environment

When developing the tool, it is possible to run commands using `yarn launch`. It relies on `tsx`, so it does not require building the project for every new change.
Expand Down
131 changes: 131 additions & 0 deletions bin/init-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/bash

set -euo pipefail

DRY_RUN=false
SCOPE=""

while [[ $# -gt 0 ]]; do
case $1 in
--dry-run)
DRY_RUN=true
shift
;;
-*)
echo "Unknown option: $1"
echo "Usage: $0 [--dry-run] <scope>"
exit 1
;;
*)
SCOPE="$1"
shift
;;
esac
done

if [ -z "$SCOPE" ]; then
echo "Usage: $0 [--dry-run] <scope>"
exit 1
fi
PLUGIN_PKG="@datadog/datadog-ci-plugin-$SCOPE"
PLUGIN_DIR="packages/plugin-$SCOPE"

if [ -d "$PLUGIN_DIR" ]; then
echo "Plugin directory $PLUGIN_DIR already exists!"
echo "This script should only be run once per scope, before migrate.sh"
exit 1
fi

BOLD='\033[1m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

echo -e "This script will initialize and publish an empty package for ${BLUE}${BOLD}$PLUGIN_PKG${NC}"
echo
echo -e "${BOLD}Please follow the instructions${NC} at ${BLUE}https://datadoghq.atlassian.net/wiki/x/QYDRaQE${NC} before running this script."
echo

read -rsp "Enter your NPM auth token: " INIT_NPM_AUTH_TOKEN
echo
if [ -z "$INIT_NPM_AUTH_TOKEN" ]; then
echo "Error: NPM auth token cannot be empty"
exit 1
fi

# Export this for subsequent yarn commands in the script
export INIT_NPM_AUTH_TOKEN

# Do not hardcode the token in .yarnrc.yml, it will be read from the environment variable
yarn config set npmAuthToken '${INIT_NPM_AUTH_TOKEN}'
echo

echo "1. Creating plugin directory structure"
mkdir -p "$PLUGIN_DIR"
env cp LICENSE "$PLUGIN_DIR"
echo "Empty package" > "$PLUGIN_DIR/README.md"
cat > "$PLUGIN_DIR/package.json" <<EOF
{
"name": "$PLUGIN_PKG",
"version": "0.0.1",
"description": "Datadog CI plugin for \`$SCOPE\` commands",
"license": "Apache-2.0",
"keywords": [
"datadog",
"datadog-ci",
"plugin"
],
"homepage": "https://github.com/DataDog/datadog-ci/tree/master/$PLUGIN_DIR",
"repository": {
"type": "git",
"url": "https://github.com/DataDog/datadog-ci.git",
"directory": "$PLUGIN_DIR"
},
"exports": {
"./package.json": "./package.json",
"./commands/*": {
"development": "./src/commands/*.ts",
"default": "./dist/commands/*.js"
}
},
"files": [
"dist/**/*",
"README",
"LICENSE"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "yarn package:clean; yarn package:build",
"lint": "yarn package:lint",
"prepack": "yarn package:clean-dist"
},
"peerDependencies": {
"@datadog/datadog-ci-base": "workspace:*"
}
}
EOF

echo "2. Publishing empty package to npm"
echo
yarn
if [ "$DRY_RUN" = true ]; then
yarn workspace "$PLUGIN_PKG" npm publish --dry-run
else
yarn workspace "$PLUGIN_PKG" npm publish
fi

echo
echo "3. Cleaning up"
yarn config unset npmAuthToken

echo
if [ "$DRY_RUN" = true ]; then
echo -e "${GREEN}[DRY-RUN] Would have published ${BOLD}$PLUGIN_PKG@0.0.1${NC}${NC}"
else
echo -e "${GREEN}Successfully published ${BOLD}$PLUGIN_PKG@0.0.1${NC}${NC}"
fi

echo
echo -e "If needed, you can now run: ${BLUE}bin/migrate.sh $SCOPE${NC}"
8 changes: 7 additions & 1 deletion bin/lint-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ if (Object.keys(impactedGithubActions).length > 0) {
// #endregion

if (fix) {
// Both commands always exit with 0, even when they make changes
exec('yarn syncpack fix')
exec('yarn syncpack format')
} else {
Expand All @@ -582,7 +583,12 @@ if (fix) {
}

if (fix) {
exec('yarn knip --fix')
try {
// This command exits with 1 when it makes changes
exec('yarn knip --fix')
} catch {
// ignore error
}
} else {
try {
exec('yarn knip')
Expand Down
Loading