Skip to content

PHP Comprehensive Coverage - v1.x backport (#282) #283

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

Merged
merged 3 commits into from
Jul 9, 2025
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
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
with:
php-version: ${{ inputs.php-version }}
extensions: "mongodb-${{ inputs.driver-version }}"
key: "extcache-v1"
key: "extcache-${{ inputs.driver-version }}"

- name: Cache extensions
uses: actions/cache@v4
Expand Down
133 changes: 133 additions & 0 deletions .github/workflows/add-redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Verify Redirects

on:
pull_request_target:

jobs:
verify-redirects:
name: Verifying Redirects
runs-on: ubuntu-latest
env:
REDIRECTS_FILE: "pr/config/redirects"
permissions:
pull-requests: write
steps:
- name: Check Out Base Branch
uses: actions/checkout@v4

- name: Checkout PR Head Branch
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: pr

- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c
with:
include_all_old_new_renamed_files: true

- name: Find Missing Redirects for Renamed Files
id: renamed-files
if: steps.changed-files.outputs.renamed_files_count > 0
env:
RENAMED_FILES: ${{ steps.changed-files.outputs.all_old_new_renamed_files }}
run: |
renamed_redirects=""

for file in $RENAMED_FILES; do

# only run for .txt files
if [[ ! "$file" == *.txt ]]; then
continue
fi

# format old and new URLs
old=$(echo "$file" | cut -d',' -f1)
old="${old#source}"
old="${old%.txt}"
new=$(echo "$file" | cut -d',' -f2)
new="${new#source}"
new="${new%.txt}"

redirect='${prefix}/${version}'"$old"'/ -> ${base}/${version}'"$new"'/'

# if redirect not already in file, add to string to add to PR description
if ! grep -q "$redirect" $REDIRECTS_FILE; then
renamed_redirects+="<li>[&lt;v&gt;-*]: $redirect</li>"
fi
done

echo "redirects=${renamed_redirects}" >> "$GITHUB_OUTPUT"

- name: Find Missing Redirects for Deleted Files
id: deleted-files
if: steps.changed-files.outputs.deleted_files_count > 0
env:
DELETED_FILES: ${{ steps.changed-files.outputs.deleted_files }}
run: |
deleted_redirects=""

for file in $DELETED_FILES; do

# only run for .txt files
if [[ ! "$file" == *.txt ]]; then
continue
fi

# format old URL
old=$(echo "$file" | cut -d',' -f1)
old="${old#source}"
old="${old%.txt}"

redirect='${prefix}/${version}'"$old"'/ -> ${base}/${version}/'

# escape special characters before searching for string
escaped_redirect=$(printf '%s\n' "$redirect" | sed 's/[[*${}|\\]/\\&/g')

# if redirect not already in file, add to string to add to PR description
if ! grep -qE "${escaped_redirect}$" $REDIRECTS_FILE; then
deleted_redirects+="<li>[&lt;v&gt;-*]: $redirect</li>"
fi
done

echo "redirects=${deleted_redirects}" >> "$GITHUB_OUTPUT"

- name: Build Redirect HTML
id: build-redirect-html
env:
RENAMED_REDIRECTS: ${{ steps.renamed-files.outputs.redirects }}
DELETED_REDIRECTS: ${{ steps.deleted-files.outputs.redirects }}
run: |
redirect_html=''
combined_redirects="${RENAMED_REDIRECTS}${DELETED_REDIRECTS}"

if [ -n "$combined_redirects" ]; then
redirect_html="<h3>Suggested redirects for moved, renamed, and deleted files:</h3><p><em>Replace &lt;v&gt; with the earliest backport target version</p></em>$combined_redirects"
fi

echo "redirect_html=${redirect_html}" >> "$GITHUB_OUTPUT"

- name: Update PR Description
uses: MongoCaleb/pr-description-action@4bdfe35b98f64532b419ad20b350a92546cd3aa1
with:
regex: "- \\[( |x)\\] Did you add redirects\\?.*"
appendContentOnMatchOnly: false
regexFlags: is
content: "- [ ] Did you add redirects?\n ${{ steps.build-redirect-html.outputs.redirect_html }}"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check for duplicates in redirects file
run: |
if [[ -f "$REDIRECTS_FILE" ]]; then
duplicates=$(sort "$REDIRECTS_FILE" | uniq -d)
if [[ -n "$duplicates" ]]; then
echo "Duplicate lines found in $REDIRECTS_FILE:"
echo "$duplicates"
exit 1 # error
fi
else
"Redirects file doesn't exist. Skipping duplicate check."
fi
1 change: 1 addition & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- "source/**/*.php"
- ".github/workflows/*.yml"
- ".github/actions/**"

env:
PHP_VERSION: "8.2"
Expand Down
56 changes: 0 additions & 56 deletions .github/workflows/static-analysis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
}
69 changes: 52 additions & 17 deletions config/redirects
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ symlink: current -> v1.21
# redirects in standardized docs
[v1.20-*]: ${prefix}/${version}/tutorial/install-php-library/ -> ${base}/${version}/get-started/download-and-install/
[v1.20-*]: ${prefix}/${version}/tutorial/connecting/ -> ${base}/${version}/connect/
[v1.20-*]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/${version}/monitoring/cluster-monitoring/
[v1.20-*]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/${version}/monitoring-logging/monitoring/
[v1.20-*]: ${prefix}/${version}/tutorial/crud/ -> ${base}/${version}/read/
[v1.20-*]: ${prefix}/${version}/tutorial/codecs/ -> ${base}/${version}/data-formats/codecs/
[v1.20-*]: ${prefix}/${version}/tutorial/collation/ -> ${base}/${version}/
Expand All @@ -35,19 +35,54 @@ symlink: current -> v1.21

# redirects in old docs
# note: this mapping does not account for all of the new pages
[*-v1.19]: ${prefix}/${version}/get-started/download-and-install/ -> ${base}/${version}/tutorial/install-php-library/
[*-v1.19]: ${prefix}/${version}/connect/ -> ${base}/${version}/tutorial/connecting/
[*-v1.19]: ${prefix}/${version}/monitoring/cluster-monitoring/ -> ${base}/${version}/tutorial/server-selection/
[*-v1.19]: ${prefix}/${version}/read/ -> ${base}/${version}/tutorial/crud/
[*-v1.19]: ${prefix}/${version}/data-formats/codecs/ -> ${base}/${version}/tutorial/codecs/
[*-v1.19]: ${prefix}/${version}/run-command/ -> ${base}/${version}/tutorial/commands/
[*-v1.19]: ${prefix}/${version}/data-formats/custom-types/ -> ${base}/${version}/tutorial/custom-types/
[*-v1.19]: ${prefix}/${version}/data-formats/decimal128/ -> ${base}/${version}/tutorial/decimal128/
[*-v1.19]: ${prefix}/${version}/security/in-use-encryption/ -> ${base}/${version}/tutorial/encryption/
[*-v1.19]: ${prefix}/${version}/write/gridfs/ -> ${base}/${version}/tutorial/gridfs/
[*-v1.19]: ${prefix}/${version}/indexes/ -> ${base}/${version}/tutorial/indexes/
[*-v1.19]: ${prefix}/${version}/read/cursor/ -> ${base}/${version}/tutorial/tailable-cursor/
[*-v1.19]: ${prefix}/${version}/data-formats/modeling-bson-data/ -> ${base}/${version}/tutorial/modeling-bson-data/
[*-v1.19]: ${prefix}/${version}/stable-api/ -> ${base}/${version}/tutorial/stable-api/
[*-v1.19]: ${prefix}/${version}/whats-new/ -> ${base}/${version}/
[*-v1.19]: ${prefix}/${version}/aws-lambda/ -> ${base}/${version}/tutorial/aws-lambda/
[*-v1.19]: ${prefix}/${version}/tutorial/install-php-library/ -> ${base}/v1.x/get-started/
[*-v1.19]: ${prefix}/${version}/tutorial/connecting/ -> ${base}/v1.x/connect/
[*-v1.19]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/v1.x/monitoring-logging/monitoring/
[*-v1.19]: ${prefix}/${version}/tutorial/crud/ -> ${base}/v1.x/read/
[*-v1.19]: ${prefix}/${version}/tutorial/codecs/ -> ${base}/v1.x/data-formats/codecs/
[*-v1.19]: ${prefix}/${version}/tutorial/collation/ -> ${base}/v1.x/
[*-v1.19]: ${prefix}/${version}/tutorial/commands/ -> ${base}/v1.x/run-command/
[*-v1.19]: ${prefix}/${version}/tutorial/custom-types/ -> ${base}/v1.x/data-formats/custom-types/
[*-v1.19]: ${prefix}/${version}/tutorial/decimal128/ -> ${base}/v1.x/data-formats/decimal128/
[*-v1.19]: ${prefix}/${version}/tutorial/encryption/ -> ${base}/v1.x/security/in-use-encryption/
[*-v1.19]: ${prefix}/${version}/tutorial/gridfs/ -> ${base}/v1.x/write/gridfs/
[*-v1.19]: ${prefix}/${version}/tutorial/indexes/ -> ${base}/v1.x/indexes/
[*-v1.19]: ${prefix}/${version}/tutorial/tailable-cursor/ -> ${base}/v1.x/read/cursor/
[*-v1.19]: ${prefix}/${version}/tutorial/example-data/ -> ${base}/v1.x/
[*-v1.19]: ${prefix}/${version}/tutorial/modeling-bson-data/ -> ${base}/v1.x/data-formats/modeling-bson-data/
[*-v1.19]: ${prefix}/${version}/tutorial/stable-api/ -> ${base}/v1.x/stable-api/
[*-v1.19]: ${prefix}/${version}/tutorial/aws-lambda/ -> ${base}/v1.x/aws-lambda/

# comprehensive coverage redirects
[*-master]: ${prefix}/${version}/aggregation/atlas-search/ -> ${base}/${version}/atlas-search/
[*-master]: ${prefix}/${version}/aws-lambda/ -> ${base}/${version}/connect/aws-lambda/
[*-master]: ${prefix}/${version}/connect/stable-api/ -> ${base}/${version}/connect/connection-options/stable-api/
[*-master]: ${prefix}/${version}/builders/ -> ${base}/${version}/crud/builders/
[*-master]: ${prefix}/${version}/write/bulk-write/ -> ${base}/${version}/crud/bulk-write/
[*-master]: ${prefix}/${version}/write/delete/ -> ${base}/${version}/crud/delete/
[*-master]: ${prefix}/${version}/write/gridfs/ -> ${base}/${version}/crud/gridfs/
[*-master]: ${prefix}/${version}/write/insert/ -> ${base}/${version}/crud/insert/
[*-master]: ${prefix}/${version}/read/count/ -> ${base}/${version}/crud/query/count/
[*-master]: ${prefix}/${version}/read/cursor/ -> ${base}/${version}/crud/query/cursor/
[*-master]: ${prefix}/${version}/read/distinct/ -> ${base}/${version}/crud/query/distinct/
[*-master]: ${prefix}/${version}/read/project/ -> ${base}/${version}/crud/query/project/
[*-master]: ${prefix}/${version}/read/retrieve/ -> ${base}/${version}/crud/query/retrieve/
[*-master]: ${prefix}/${version}/read/specify-a-query/ -> ${base}/${version}/crud/query/specify-a-query/
[*-master]: ${prefix}/${version}/read/specify-documents-to-return/ -> ${base}/${version}/crud/query/specify-documents-to-return/
[*-master]: ${prefix}/${version}/read-write-pref/ -> ${base}/${version}/crud/read-write-pref/
[*-master]: ${prefix}/${version}/write/replace/ -> ${base}/${version}/crud/replace/
[*-master]: ${prefix}/${version}/write/transaction/ -> ${base}/${version}/crud/transaction/
[*-master]: ${prefix}/${version}/write/update/ -> ${base}/${version}/crud/update/
[*-master]: ${prefix}/${version}/data-formats/codecs/ -> ${base}/${version}/data-formats/custom-types/codecs/
[*-master]: ${prefix}/${version}/databases-collections/time-series/ -> ${base}/${version}/data-formats/time-series/
[*-master]: ${prefix}/${version}/read/change-streams/ -> ${base}/${version}/monitoring-logging/change-streams/
[*-master]: ${prefix}/${version}/monitoring/cluster-monitoring/ -> ${base}/${version}/monitoring-logging/monitoring/
[*-master]: ${prefix}/${version}/compatibility/ -> ${base}/${version}/references/compatibility/
[*-master]: ${prefix}/${version}/whats-new/ -> ${base}/${version}/references/release-notes/
[*-master]: ${prefix}/${version}/upgrade/ -> ${base}/${version}/references/upgrade/
[*-master]: ${prefix}/${version}/connect/tls/ -> ${base}/${version}/security/tls/
[*-master]: ${prefix}/${version}/aggregation/vector-search/ -> ${base}/${version}/vector-search/
[*-master]: ${prefix}/${version}/monitoring/ -> ${base}/${version}/monitoring-logging/
[*-master]: ${prefix}/${version}/read/ -> ${base}/${version}/crud/
[*-master]: ${prefix}/${version}/write/ -> ${base}/${version}/crud/
[*-master]: ${prefix}/${version}/faq/ -> ${base}/${version}/
Loading
Loading