Skip to content

Commit

Permalink
Support for Windows release validation (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
swebb2066 authored Jan 14, 2025
1 parent f08a45d commit 7bf9fc1
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 8 deletions.
38 changes: 30 additions & 8 deletions admin/release-review-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,30 @@ The steps below use version 1.4.0 as an example.
Prerequisites
----------

* [GNU Privacy Guard](https://www.gnupg.org/) is installed on your system
* A C++ compiler is available on your system
* cmake, APR and APR-Util are installed on your system
* [GNU Privacy Guard](https://www.gnupg.org/) is installed on your system
* You have imported the [Apache Logging KEYS file](https://dist.apache.org/repos/dist/release/logging/KEYS)

Additional Prerequisites (Windows only)
----------

* The `PATH` environment variable includes directories containing `cmake.exe` and `gpg.exe`
* One of these environment variables is set (using / directory separators):
- `CMAKE_TOOLCHAIN_FILE` - The full path to the `vcpkg.cmake` file (where APR-Util is installed)
- `CMAKE_INSTALL_PREFIX` - The full path to the directory where EXPAT, APR and APR-Util libraries are installed
* If the programs `zip.exe`, `gzip.exe` and `sed.exe` are not in `C:/msys64/usr/bin`, the environment has a variable `LOG4CXX_TEST_PROGRAM_PATH` set to the full path containing those programs

Steps
-----

1. Download, verify check-sums, verify signatures, build and test
- Save to your system the verification script https://github.com/apache/logging-log4cxx/blob/master/admin/validate-release.sh
- Save to your system a verification script from https://github.com/apache/logging-log4cxx/blob/master/admin
- Linux, MacOS: `validate-release.sh`
- Windows: `validate-release.ps1`
- Run the script
- For success, the final output line needs to include:
- `100% tests passed, 0 tests failed out of 62`
- `100% tests passed, 0 tests failed out of 63`
1. Download the packaged release files from Github
- Open https://github.com/apache/logging-log4cxx/commits/v1.4.0-RC1 in your web browser
- Click the green tick mark on the top commit
Expand All @@ -32,8 +43,19 @@ Steps
- Click the link next to `Artifact download URL:`
- The browser will download the file `release_files.zip` onto your system
1. Confirm the artifacts were sourced from Github using these commands
- `mkdir /tmp/log4cxx-github`
- `cd /tmp/log4cxx-github`
- `unzip "$HOME/Downloads/release_files.zip"`
- `diff /tmp/log4cxx-{1.4.0,github}/apache-log4cxx-1.4.0.tar.gz.sha512`
- `diff /tmp/log4cxx-{1.4.0,github}/apache-log4cxx-1.4.0.zip.sha512`
- Linux, MacOS (bash):
- `cd /tmp/log4cxx-1.4.0`
- `unzip $HOME/Downloads/release_files.zip -d github`
- `ARCHIVE=apache-log4cxx-1.4.0`
- `for TYPE in tar.gz zip; do`
- `diff {,github/}$ARCHIVE.$TYPE.sha512 && echo "$ARCHIVE.$TYPE.sha512: OK"`
- `done`
- Windows (powershell):
- `Set-Location -Path "${ENV:TEMP}\log4cxx-1.4.0"`
- `Expand-Archive -Path "${ENV:HOMEPATH}\Downloads\release_files.zip" -DestinationPath "github"`
- `$ARCHIVE="apache-log4cxx-1.4.0"`
- `foreach ($TYPE in @("tar.gz", "zip")) {`
- `` if (@(Get-Content -Path "$ARCHIVE.$TYPE.sha512")[0]` ``
- `-eq @(Get-Content -Path "github\$ARCHIVE.$TYPE.sha512")[0]) {`
- `Write-Output "$ARCHIVE.$TYPE.sha512: OK" } }`

91 changes: 91 additions & 0 deletions admin/validate-release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

# Allow the version to be provided as a parameter
param ( [string]$VERSION )
if (-not $VERSION) { $VERSION = "1.4.0" }

$STAGE="dev"
#$STAGE="release"
if ( ${ENV:STAGE} ) { $STAGE = ${ENV:STAGE} }

$BASE_DL="https://dist.apache.org/repos/dist/$STAGE/logging/log4cxx"
if ( ${ENV:BASE_DL} ) { $BASE_DL = ${ENV:BASE_DL} }

$ARCHIVE="apache-log4cxx-$VERSION"
if ( ${ENV:ARCHIVE} ) { $ARCHIVE = ${ENV:ARCHIVE} }

$TEST_DIRECTORY="${ENV:TEMP}/log4cxx-$VERSION"
if ( ${ENV:TEST_DIRECTORY} ) { $TEST_DIRECTORY = "${ENV:TEST_DIRECTORY}" }

try
{
gpg --version | Out-Null
}
catch
{
Write-Error "The gpg program directory must be included the PATH environment variable" -ErrorAction Stop
}

if (-not (Test-Path -Path "$TEST_DIRECTORY" -PathType Container))
{
New-Item -ItemType Directory -Path "$TEST_DIRECTORY" -ErrorAction Stop
}
Set-Location -Path "$TEST_DIRECTORY"

$FULL_DL="$BASE_DL/$VERSION/$ARCHIVE"
$ARCHIVE_TYPES = @("tar.gz", "zip")
foreach ($ARCHIVE_TYPE in $ARCHIVE_TYPES)
{
if (Test-Path "$ARCHIVE.$ARCHIVE_TYPE") { Remove-Item "$ARCHIVE.$ARCHIVE_TYPE" }
Invoke-WebRequest -Uri "$FULL_DL.$ARCHIVE_TYPE" -OutFile "$ARCHIVE.$ARCHIVE_TYPE" -ErrorAction Stop
$EXTS = @("asc", "sha512", "sha256")
foreach ($EXT in $EXTS)
{
if (Test-Path "$ARCHIVE.$ARCHIVE_TYPE.$EXT") { Remove-Item "$ARCHIVE.$ARCHIVE_TYPE.$EXT" }
Invoke-WebRequest -Uri "$FULL_DL.$ARCHIVE_TYPE.$EXT" -OutFile "$ARCHIVE.$ARCHIVE_TYPE.$EXT" -ErrorAction Stop
}
$SUMS = @("sha512", "sha256")
foreach ($SUM in $SUMS)
{
Write-Output "Validating $ARCHIVE.$ARCHIVE_TYPE $SUM checksum..."
$Line = @(Get-Content -Path "$ARCHIVE.$ARCHIVE_TYPE.$SUM")[0]
$Fields = $Line -split '\s+'
$Hash = $Fields[0].Trim().ToUpper()
$ComputedHash = (Get-FileHash -Algorithm $SUM -Path "$ARCHIVE.$ARCHIVE_TYPE").Hash.ToUpper()
if ($Hash -ne $ComputedHash)
{
Write-Error "Read from $ARCHIVE.$ARCHIVE_TYPE.${SUM}: $Hash" -ErrorAction Continue
Write-Error "Computed: $ComputedHash" -ErrorAction Continue
Write-Error "${File}: Not Passed" -ErrorAction Stop
}
}
Write-Output "Validating $ARCHIVE.$ARCHIVE_TYPE signature..."
gpg --verify "$ARCHIVE.$ARCHIVE_TYPE.asc"
if (!$? ) { exit 1 }
}

if (Test-Path "$ARCHIVE") { Remove-Item -Recurse "$ARCHIVE" }
if (Test-Path test-build) { Remove-Item -Recurse test-build }
Write-Output "Extracting files..."
Expand-Archive -Path "$ARCHIVE.zip" -DestinationPath . -ErrorAction Stop

# Check tools are on the PATH
try
{
cmake --version | Out-Null
}
catch
{
Write-Error "The cmake program directory must be included the PATH environment variable" -ErrorAction Stop
}

${LOG4CXX_TEST_PROGRAM_PATH}="C:/msys64/usr/bin"
if ( ${ENV:LOG4CXX_TEST_PROGRAM_PATH} ) { $LOG4CXX_TEST_PROGRAM_PATH = ${ENV:LOG4CXX_TEST_PROGRAM_PATH} }
cmake -S $ARCHIVE -B test-build "-DLOG4CXX_TEST_PROGRAM_PATH=$LOG4CXX_TEST_PROGRAM_PATH"
if ( ! $? ) { exit 1 }

cmake --build test-build --config Release
if ( ! $? ) { exit 1 }

Set-Location -Path test-build
ctest -C Release --output-on-failure

0 comments on commit 7bf9fc1

Please sign in to comment.