Skip to content

ci: add workflow to mirror MCR images to GHCR (#6921) #85

ci: add workflow to mirror MCR images to GHCR (#6921)

ci: add workflow to mirror MCR images to GHCR (#6921) #85

Workflow file for this run

name: Nightly
on:
workflow_dispatch: {}
push:
branches:
- "main"
schedule:
- cron: '00 03 * * *'
jobs:
nightly:
strategy:
matrix:
library:
- cpp
- cpp_httpd
- dotnet
- golang
- java
- nodejs
- php
- python
- python_lambda
- nodejs_lambda
- ruby
- cpp_nginx
version:
- prod
include:
- library: rust
version: dev
fail-fast: false
uses: ./.github/workflows/system-tests.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
permissions:
contents: read
id-token: write
with:
scenarios_groups: tracer_release
library: ${{ matrix.library }}
parametric_job_count: 8
_system_tests_dev_mode: ${{ matrix.version == 'dev' }}
push_to_test_optimization: true
create_test_report:
name: Create test report
permissions:
contents: read
packages: read
if: (success() || failure()) && github.event_name == 'schedule'
needs:
- nightly
runs-on: ubuntu-latest
steps:
- name: Download logs artifact
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
merge-multiple: false
pattern: logs_*
- name: Uncompress logs
run: |
for d in logs_*; do
if [ -f "$d/artifact.tar.gz" ]; then
tar -xzf "$d/artifact.tar.gz" -C "$d" --wildcards '*/report.json' || true
fi
done
- name: Upload test report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-report
path: |
logs_*
!logs_*/artifact.tar.gz
test_activation:
name: Test activation
runs-on: ubuntu-latest
if: (success() || failure()) && github.event_name == 'schedule'
strategy:
fail-fast: false
matrix:
library:
- cpp
- cpp_httpd
- cpp_nginx
- dotnet
- golang
- java
- nodejs
- php
- python
- python_lambda
- nodejs_lambda
- ruby
- rust
include:
- library: cpp
exclude_owners: ""
use_dev: ""
- library: cpp_httpd
exclude_owners: ""
use_dev: ""
- library: cpp_nginx
exclude_owners: ""
use_dev: ""
- library: dotnet
exclude_owners: ""
use_dev: ""
- library: golang
exclude_owners: ""
use_dev: ""
- library: java
exclude_owners: ""
use_dev: ""
- library: nodejs
exclude_owners: ""
use_dev: ""
- library: php
exclude_owners: ""
use_dev: ""
- library: python
exclude_owners: ""
use_dev: ""
- library: python_lambda
exclude_owners: ""
use_dev: ""
- library: nodejs_lambda
exclude_owners: ""
use_dev: ""
- library: ruby
exclude_owners: ""
use_dev: ""
- library: rust
exclude_owners: ""
use_dev: "true"
permissions:
contents: read
actions: read
id-token: write
needs:
- create_test_report
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
repository: DataDog/system-tests
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
name: test-report
path: data
- uses: DataDog/system-tests/.github/actions/install_runner@main
- name: Install additional dependencies
shell: bash
run: |
source venv/bin/activate
python -m pip install --upgrade pip ruamel.yaml requests tqdm pygtrie
- name: Configure git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Run activation script
id: activation_script
shell: bash
run: |
source venv/bin/activate
set +e
EXTRA_ARGS=""
if [[ -n "${{ matrix.exclude_owners }}" ]]; then
EXTRA_ARGS="$EXTRA_ARGS --exclude ${{ matrix.exclude_owners }}"
fi
if [[ -n "${{ matrix.use_dev }}" ]]; then
EXTRA_ARGS="$EXTRA_ARGS --dev"
fi
python -m utils.scripts.activate_easy_wins --no-download --split-co --components "${{ matrix.library }}" $EXTRA_ARGS
EXIT_CODE=$?
set -e
echo "activation_exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
# Collect branches created by --split-co
BRANCHES=$(git branch --list 'easy-win/*/${{ matrix.library }}' --format='%(refname:short)' | tr '\n' ' ')
echo "branches=$BRANCHES" >> "$GITHUB_OUTPUT"
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
id: octo-sts
if: steps.activation_script.outputs.activation_exit_code == '0' && steps.activation_script.outputs.branches != ''
with:
scope: DataDog/system-tests
policy: self.test-activation-github
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
if: steps.activation_script.outputs.activation_exit_code == '0' && steps.activation_script.outputs.branches != ''
with:
repository: DataDog/commit-headless
ref: action/v3.3.0
path: .commit-headless
- name: Push signed branches and create PRs
if: steps.activation_script.outputs.activation_exit_code == '0' && steps.activation_script.outputs.branches != ''
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
shell: bash
run: |
gh auth setup-git
chmod +x .commit-headless/dist/commit-headless-linux-amd64
COMMIT_HEADLESS=".commit-headless/dist/commit-headless-linux-amd64"
for BRANCH_NAME in ${{ steps.activation_script.outputs.branches }}; do
echo "============ Processing $BRANCH_NAME ============"
# Extract owner name from branch: easy-win/<owner>/<library> -> <owner>
OWNER=$(echo "$BRANCH_NAME" | cut -d'/' -f2)
# Check if a PR already exists for this branch
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null || true)
if [[ -n "$PR_NUMBER" ]]; then
# Skip if the PR has any activity (comments, reviews, or extra commits)
COMMENTS=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" --jq '[.[] | select(.user.login | endswith("[bot]") | not)] | length')
REVIEWS=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}/reviews" --jq 'length')
COMMITS=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}/commits" --jq 'length')
if [[ "$COMMENTS" -gt 0 || "$REVIEWS" -gt 0 || "$COMMITS" -gt 1 ]]; then
echo "PR #$PR_NUMBER for $BRANCH_NAME has activity (comments=$COMMENTS, reviews=$REVIEWS, commits=$COMMITS), skipping"
continue
fi
echo "PR #$PR_NUMBER exists but has no activity, updating"
fi
git checkout "$BRANCH_NAME"
MAIN_SHA=$(git rev-parse main)
if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then
SIGNED_COMMIT=$(git log --reverse --format="%H" "$MAIN_SHA..HEAD" | \
HEADLESS_TOKEN="$GITHUB_TOKEN" $COMMIT_HEADLESS push \
-T "${{ github.repository }}" --branch "$BRANCH_NAME" \
--head-sha "$MAIN_SHA" --force)
else
SIGNED_COMMIT=$(git log --reverse --format="%H" "$MAIN_SHA..HEAD" | \
HEADLESS_TOKEN="$GITHUB_TOKEN" $COMMIT_HEADLESS push \
-T "${{ github.repository }}" --branch "$BRANCH_NAME" \
--head-sha "$MAIN_SHA" --create-branch)
fi
echo "Pushed signed commit $SIGNED_COMMIT to $BRANCH_NAME"
# Create PR if it doesn't exist
if [[ -z "$PR_NUMBER" ]]; then
gh pr create \
--title "Auto-activate ${{ matrix.library }} easy wins for $OWNER" \
--body "Automated activation of easy-win tests for \`${{ matrix.library }}\` owned by \`$OWNER\`
[View nightly workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
- If you approve this PR please also merge it.
- If the tests are failing it might be due to a change made since the last nightly system-tests run. You can close the PR, an updated one will be available tomorrow.
- If you close the PR please also delete the branch" \
--head "$BRANCH_NAME" \
--base main
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
fi
# Enable auto-merge on the PR
echo "Enabling auto-merge on PR #$PR_NUMBER..."
gh pr merge "$PR_NUMBER" --auto --squash
done