-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1081 from Ana06/compare_packages
[CI] Check daily that local versions match MyGet
- Loading branch information
Showing
3 changed files
with
98 additions
and
0 deletions.
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,44 @@ | ||
name: MyGet version mitmatches | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# Runs daily at a weird time (02:41 UTC) to avoid delays during periods of | ||
# high loads of GitHub Actions workflow runs. | ||
- cron: '41 2 * * *' | ||
|
||
|
||
jobs: | ||
update_badge: | ||
runs-on: windows-2022 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Checkout wiki code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: ${{ github.repository }}.wiki | ||
path: wiki | ||
- name: Add results to wiki | ||
run: | | ||
$mismatches=$(python scripts/utils/compare_myget.py) | ||
echo "mismatches=$mismatches" >> $env:GITHUB_ENV | ||
- name: Commit changes | ||
working-directory: wiki | ||
run: | | ||
git config user.email '[email protected]' | ||
git config user.name 'vm-packages' | ||
git commit -am 'Add MyGet mismatches' | ||
git push | ||
- name: Update dynamic badge gist | ||
uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0 | ||
with: | ||
auth: ${{ secrets.REPO_TOKEN }} | ||
gistID: dfe6ed22576b6c1d2fa749ff46f3bc6f | ||
filename: myget_badge.svg | ||
label: 'MyGet mismatches' | ||
message: ${{ env.mismatches }} | ||
valColorRange: ${{ env.mismatches }} | ||
maxColorRange: 1 | ||
minColorRange: 0 | ||
invertColorRange: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import glob | ||
import os | ||
import re | ||
|
||
log_file = "wiki/MyGet-Version-Mismatches.md" | ||
source = "https://www.myget.org/F/vm-packages/api/v2" | ||
|
||
# Convert 1.02.0 to 1.2 to ensure we compare versions consistency | ||
def format_version(version): | ||
version = re.sub("\.0(?P<digit>\d)", lambda x: f".{x.group('digit')}", version) | ||
return re.sub("(\.0+)+$", "", version) | ||
|
||
|
||
def get_remote_version(package_name): | ||
stream = os.popen(f"powershell.exe choco find -er {package_name} -s {source}") | ||
output = stream.read() | ||
m = re.search(f"^{package_name}\|(?P<version>.+)", output, re.M) | ||
if not m: | ||
return '' | ||
return m.group("version") | ||
|
||
|
||
mismatches = [] | ||
nuspecs_path = "packages/*/*.nuspec" | ||
nuspecs = glob.glob(nuspecs_path) | ||
for nuspec in nuspecs: | ||
with open(nuspec, "r") as file: | ||
nuspec_content = file.read() | ||
|
||
# Find local package version | ||
m = re.search("<id>(?P<name>[^<]+)</id>", nuspec_content) | ||
m2 = re.search("<version>(?P<version>[^<]+)</version>", nuspec_content) | ||
|
||
if (m and m2): | ||
name = m.group("name") | ||
local_version = m2.group("version") | ||
my_get_version = get_remote_version(name) | ||
if format_version(local_version) != format_version(my_get_version): | ||
mismatches.append([name, my_get_version, local_version]) | ||
|
||
log_f = open(log_file, "w") | ||
if not mismatches: | ||
log_f.write("**All local versions match MyGet versions** :tada:") | ||
else: | ||
W1 = 40 | ||
W2 = 25 | ||
log_f.write("The following packages local version do not match the latest version in MyGet.\n\n") | ||
log_f.write(f"| {'Package Name'.ljust(W1)} | {'MyGet version'.ljust(W2)} | {'Local version'.ljust(W2)} |\n|-|-|-|\n") | ||
for mismatch in mismatches: | ||
log_f.write(f"| {mismatch[0].ljust(W1)} | {mismatch[1].rjust(W2)} | {mismatch[2].rjust(W2)} |\n") | ||
|
||
print(len(mismatches)) | ||
|