From 4b661385be6d8043f7aafe6d4c66f9bafa4a9c4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:18:34 +0000 Subject: [PATCH 1/5] Bump tzinfo from 1.2.2 to 1.2.10 in /test_projects/mojombo Bumps [tzinfo](https://github.com/tzinfo/tzinfo) from 1.2.2 to 1.2.10. - [Release notes](https://github.com/tzinfo/tzinfo/releases) - [Changelog](https://github.com/tzinfo/tzinfo/blob/master/CHANGES.md) - [Commits](https://github.com/tzinfo/tzinfo/compare/v1.2.2...v1.2.10) --- updated-dependencies: - dependency-name: tzinfo dependency-type: indirect ... Signed-off-by: dependabot[bot] --- test_projects/mojombo/Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_projects/mojombo/Gemfile.lock b/test_projects/mojombo/Gemfile.lock index ebac303..ee7f0f3 100644 --- a/test_projects/mojombo/Gemfile.lock +++ b/test_projects/mojombo/Gemfile.lock @@ -128,10 +128,10 @@ GEM faraday (~> 0.8, < 0.10) terminal-table (1.7.3) unicode-display_width (~> 1.1.1) - thread_safe (0.3.5) + thread_safe (0.3.6) typhoeus (0.8.0) ethon (>= 0.8.0) - tzinfo (1.2.2) + tzinfo (1.2.10) thread_safe (~> 0.1) unicode-display_width (1.1.1) From d9d253201f943e5b6492524f3c77d7411cf0b5d6 Mon Sep 17 00:00:00 2001 From: Yoann Chaudet Date: Wed, 27 Jul 2022 13:15:40 -0700 Subject: [PATCH 2/5] wip --- bin/record_expected_output | 16 +++--- bin/sync_expected_output.ps1 | 103 +++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 8 deletions(-) create mode 100755 bin/sync_expected_output.ps1 diff --git a/bin/record_expected_output b/bin/record_expected_output index d90ab1f..8d88bdc 100755 --- a/bin/record_expected_output +++ b/bin/record_expected_output @@ -1,14 +1,14 @@ #! /usr/bin/env sh if [ "local" = "$1" ]; then - export JEKYLL_ENV=production - export PAGES_REPO_NWO=actions/jekyll-build-pages - export JEKYLL_BUILD_REVISION=JEKYLL_BUILD_REVISION + export JEKYLL_ENV=production + export PAGES_REPO_NWO=actions/jekyll-build-pages + export JEKYLL_BUILD_REVISION=JEKYLL_BUILD_REVISION - for dir in $(ls test_projects) - do - bundle exec github-pages build --verbose -s test_projects/$dir -d test_projects/$dir/_expected - done + for dir in $(ls test_projects) + do + bundle exec github-pages build --verbose -s test_projects/$dir -d test_projects/$dir/_expected + done else - act -b -s GITHUB_TOKEN -j record-expected-output + act -b -s GITHUB_TOKEN -j record-expected-output fi diff --git a/bin/sync_expected_output.ps1 b/bin/sync_expected_output.ps1 new file mode 100755 index 0000000..8aa82f3 --- /dev/null +++ b/bin/sync_expected_output.ps1 @@ -0,0 +1,103 @@ +#!/usr/bin/env pwsh +#Requires -Version 7.2 + +<# +.SYNOPSIS +Trigger the workflow that records the tests expected outputs, wait for its execution to finish, +then bring back those results locally. + +.DESCRIPTION +This script is meant to run locally outside of Actions. It relies on `gh` and `git`. +#> + +# Get the repository's path (ps1 extension on the script is required for PSScriptRoot to be available 🤦) +$repositoryPath = Resolve-Path (Join-Path $PSScriptRoot '..') + +# Get the test_project's path +$testProjectsPath = Resolve-Path (Join-Path $PSScriptRoot '../test_projects') + +# +# Utilities +# + +# Run a command and validate it returned a 0 exit code +function Invoke-Command { + param ( + [ScriptBlock] $Command + ) + + & $Command + if ($LASTEXITCODE -ne 0) { + Write-Error "Command failed: $Command" + throw + } +} + +# Get the current git ref name +function Get-GitRef { + $commitId = Invoke-Command { & git -C $repositoryPath rev-parse --abbrev-ref HEAD } + $commitId.Trim() +} + +# Create a temp folder and return its path +function New-TemporaryFolder { + $path = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid()) + New-Item -ItemType 'Directory' -Path $path | Out-Null + $path +} + +# +# Main +# + +# Init +Set-StrictMode -version 'Latest' +$ErrorActionPreference = 'Stop' + +# Get git ref name +$ref = Get-GitRef + +# # Run the workflow +# Write-Host 'Queue workflow' +# $workflow = 'record.yml' +# Invoke-Command { & gh workflow run $workflow --ref $ref | Out-Null } + +# # Wait for a few seconds for the workflow to get created +# Write-Host 'Wait a few seconds...' +# Start-Sleep -Seconds 5 + +# # Lookup the run id (it is not perfect because of the APIs...) +# Write-Host 'Lookup run id' +# $runId = Invoke-Command { & gh run list --workflow $workflow --branch $ref --limit 100 --json databaseId --jq '.[].databaseId' } + +# # Wait for the workflow to finish +# Write-Host "Wait for workflow $runId to complete" +# Invoke-Command { & gh run watch $runId --exit-status } + +# # Download the artifacts in a temp folder +# Write-Host 'Download artifacts' +# $tempFolder = New-TemporaryFolder +# Invoke-Command { & gh run download $runId --dir $tempFolder } + + +# TEMP +$tempFolder = '/var/folders/0p/xh302z2x64b64_4l9xc5n7bm0000gn/T/959ec25f-986e-48b1-b6a8-155cd7ba62fe' + +Write-Host $tempFolder +$runId = 2748946582 + +# Iterate over the test projects +Get-ChildItem -Path $testProjectsPath -Directory | ForEach-Object { + # Construct the artifact path and make sure a matching artifact is found + $artifactPath = Join-Path $tempFolder $_.BaseName + if (Test-Path $artifactPath -PathType 'Container') { + # Copy artifact to the expected output folder + $destinationPath = Join-Path $testProjectsPath $_.BaseName '_expected' + Copy-Item -Path $artifactPath -Destination $destinationPath -Recurse | Out-Null + } + + # Ignore test project + else { + Write-Warning "Unable to find artifact for test project $($_.BaseName)" + } +} From f64a106cc1539013f7a6834dc50c44b068fe0af9 Mon Sep 17 00:00:00 2001 From: Yoann Chaudet Date: Wed, 27 Jul 2022 13:18:49 -0700 Subject: [PATCH 3/5] Add script to sync expected output --- bin/sync_expected_output.ps1 | 43 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/bin/sync_expected_output.ps1 b/bin/sync_expected_output.ps1 index 8aa82f3..5ca6a6e 100755 --- a/bin/sync_expected_output.ps1 +++ b/bin/sync_expected_output.ps1 @@ -57,34 +57,27 @@ $ErrorActionPreference = 'Stop' # Get git ref name $ref = Get-GitRef -# # Run the workflow -# Write-Host 'Queue workflow' -# $workflow = 'record.yml' -# Invoke-Command { & gh workflow run $workflow --ref $ref | Out-Null } +# Run the workflow +Write-Host 'Queue workflow' +$workflow = 'record.yml' +Invoke-Command { & gh workflow run $workflow --ref $ref | Out-Null } -# # Wait for a few seconds for the workflow to get created -# Write-Host 'Wait a few seconds...' -# Start-Sleep -Seconds 5 +# Wait for a few seconds for the workflow to get created +Write-Host 'Wait a few seconds...' +Start-Sleep -Seconds 5 -# # Lookup the run id (it is not perfect because of the APIs...) -# Write-Host 'Lookup run id' -# $runId = Invoke-Command { & gh run list --workflow $workflow --branch $ref --limit 100 --json databaseId --jq '.[].databaseId' } +# Lookup the run id (it is not perfect because of the APIs...) +Write-Host 'Lookup run id' +$runId = Invoke-Command { & gh run list --workflow $workflow --branch $ref --limit 100 --json databaseId --jq '.[].databaseId' } -# # Wait for the workflow to finish -# Write-Host "Wait for workflow $runId to complete" -# Invoke-Command { & gh run watch $runId --exit-status } +# Wait for the workflow to finish +Write-Host "Wait for workflow $runId to complete" +Invoke-Command { & gh run watch $runId --exit-status } -# # Download the artifacts in a temp folder -# Write-Host 'Download artifacts' -# $tempFolder = New-TemporaryFolder -# Invoke-Command { & gh run download $runId --dir $tempFolder } - - -# TEMP -$tempFolder = '/var/folders/0p/xh302z2x64b64_4l9xc5n7bm0000gn/T/959ec25f-986e-48b1-b6a8-155cd7ba62fe' - -Write-Host $tempFolder -$runId = 2748946582 +# Download the artifacts in a temp folder +Write-Host 'Download artifacts' +$tempFolder = New-TemporaryFolder +Invoke-Command { & gh run download $runId --dir $tempFolder } # Iterate over the test projects Get-ChildItem -Path $testProjectsPath -Directory | ForEach-Object { @@ -93,7 +86,7 @@ Get-ChildItem -Path $testProjectsPath -Directory | ForEach-Object { if (Test-Path $artifactPath -PathType 'Container') { # Copy artifact to the expected output folder $destinationPath = Join-Path $testProjectsPath $_.BaseName '_expected' - Copy-Item -Path $artifactPath -Destination $destinationPath -Recurse | Out-Null + Copy-Item -Path (Join-Path $artifactPath '*') -Destination $destinationPath -Recurse -Force | Out-Null } # Ignore test project From d7e8b2cc0771ccb7cd9807eabd713f7bd3572868 Mon Sep 17 00:00:00 2001 From: Yoann Chaudet Date: Wed, 27 Jul 2022 13:22:03 -0700 Subject: [PATCH 4/5] Fix script --- bin/sync_expected_output.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sync_expected_output.ps1 b/bin/sync_expected_output.ps1 index 5ca6a6e..ce3fbb7 100755 --- a/bin/sync_expected_output.ps1 +++ b/bin/sync_expected_output.ps1 @@ -68,7 +68,7 @@ Start-Sleep -Seconds 5 # Lookup the run id (it is not perfect because of the APIs...) Write-Host 'Lookup run id' -$runId = Invoke-Command { & gh run list --workflow $workflow --branch $ref --limit 100 --json databaseId --jq '.[].databaseId' } +$runId = Invoke-Command { & gh run list --workflow $workflow --branch $ref --limit 1 --json databaseId --jq '.[].databaseId' } # Wait for the workflow to finish Write-Host "Wait for workflow $runId to complete" From eaf5f4fbedc7abb3cf98e5dca7d83de5eaec9b52 Mon Sep 17 00:00:00 2001 From: Yoann Chaudet Date: Wed, 27 Jul 2022 13:27:25 -0700 Subject: [PATCH 5/5] Sync tests --- test_projects/jekyll-include-cache/_expected/index.html | 6 ++++-- test_projects/octicons/_expected/index.html | 4 +++- test_projects/readme/_expected/index.html | 4 +++- test_projects/simple/_expected/index.html | 6 ++++-- test_projects/themes/_expected/index.html | 8 +++++--- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/test_projects/jekyll-include-cache/_expected/index.html b/test_projects/jekyll-include-cache/_expected/index.html index 9f2af89..91f256a 100644 --- a/test_projects/jekyll-include-cache/_expected/index.html +++ b/test_projects/jekyll-include-cache/_expected/index.html @@ -6,10 +6,12 @@ -jekyll-build-pages +jekyll-build-pages | A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages. + + @@ -17,7 +19,7 @@ +{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"jekyll-build-pages","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"} diff --git a/test_projects/octicons/_expected/index.html b/test_projects/octicons/_expected/index.html index 4ba3b74..aa68d57 100644 --- a/test_projects/octicons/_expected/index.html +++ b/test_projects/octicons/_expected/index.html @@ -10,6 +10,8 @@ + + @@ -17,7 +19,7 @@ +{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"Readme Test","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"} diff --git a/test_projects/readme/_expected/index.html b/test_projects/readme/_expected/index.html index 4397b96..c346db8 100644 --- a/test_projects/readme/_expected/index.html +++ b/test_projects/readme/_expected/index.html @@ -10,6 +10,8 @@ + + @@ -17,7 +19,7 @@ +{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"Readme Test","name":"jekyll-build-pages","url":"https://github.com/pages/actions/jekyll-build-pages/"} diff --git a/test_projects/simple/_expected/index.html b/test_projects/simple/_expected/index.html index aecb01d..4d34bbc 100644 --- a/test_projects/simple/_expected/index.html +++ b/test_projects/simple/_expected/index.html @@ -6,10 +6,12 @@ -Jekyll Actions Demo +Jekyll Actions Demo | A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages. + + @@ -17,7 +19,7 @@ +{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"Jekyll Actions Demo","name":"Jekyll Actions Demo","url":"https://github.com/pages/actions/jekyll-build-pages/"} diff --git a/test_projects/themes/_expected/index.html b/test_projects/themes/_expected/index.html index 340bc65..9d007d6 100644 --- a/test_projects/themes/_expected/index.html +++ b/test_projects/themes/_expected/index.html @@ -6,10 +6,12 @@ -themes +themes | A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages. + + @@ -17,7 +19,7 @@ +{"@context":"https://schema.org","@type":"WebSite","description":"A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.","headline":"themes","name":"themes","url":"https://github.com/pages/actions/jekyll-build-pages/"} @@ -43,7 +45,7 @@

themes

+

A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.

View the Project on GitHub actions/jekyll-build-pages