From faa5503887b6258f1d7c975dcf7c8c55a2710cee Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 00:30:33 -0500 Subject: [PATCH 01/15] extract julia directly to tool path --- lib/installer.js | 23 +++++++++++------------ lib/setup-julia.js | 16 +++++++++++----- src/installer.ts | 24 +++++++++++------------- src/setup-julia.ts | 17 ++++++++++++----- 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/lib/installer.js b/lib/installer.js index 47f62784..f1aba02b 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -216,7 +216,7 @@ function getDownloadURL(fileInfo, version, arch) { return fileInfo.url; } exports.getDownloadURL = getDownloadURL; -function installJulia(versionInfo, version, arch) { +function installJulia(dest, versionInfo, version, arch) { return __awaiter(this, void 0, void 0, function* () { // Download Julia const fileInfo = getFileInfo(versionInfo, version, arch); @@ -243,39 +243,38 @@ function installJulia(versionInfo, version, arch) { else { core.debug('Skipping checksum check for nightly binaries.'); } - const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`); // Install it switch (osPlat) { case 'linux': // tc.extractTar doesn't support stripping components, so we have to call tar manually - yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]); - return tempInstallDir; + yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]); + return dest; case 'win32': if (fileInfo !== null && fileInfo.extension == 'exe') { if (version.endsWith('nightly') || semver.gtr(version, '1.3', { includePrerelease: true })) { // The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes - yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]); + yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]); } else { - yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]); + yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]); } } else { // This is the more common path. Using .tar.gz is much faster - yield exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${tempInstallDir}`]); + yield exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${dest}`]); } - return tempInstallDir; + return dest; case 'darwin': if (fileInfo !== null && fileInfo.extension == 'dmg') { core.debug(`Support for .dmg files is deprecated and may be removed in a future release`); yield exec.exec('hdiutil', ['attach', juliaDownloadPath]); - yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]); - return path.join(tempInstallDir, 'julia'); + yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${dest}`]); + return path.join(dest, 'julia'); } else { // tc.extractTar doesn't support stripping components, so we have to call tar manually - yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]); - return tempInstallDir; + yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]); + return dest; } default: throw new Error(`Platform ${osPlat} is not supported`); diff --git a/lib/setup-julia.js b/lib/setup-julia.js index eb81dfa3..4657e0b8 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -91,12 +91,18 @@ function run() { juliaPath = tc.find('julia', version, arch); if (!juliaPath) { core.debug(`could not find Julia ${arch}/${version} in cache`); - const juliaInstallationPath = yield installer.installJulia(versionInfo, version, arch); - // Add it to cache - juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch); + // we want julia to be installed with unmodified file mtimes + // but tc.cacheDir uses `cp` which destroys mtime + // and `tc` provides no API to get the tool directory alone + // so hack it by installing a dummy julia file then use the path it returns + // and extract the archives directly to that location + const tempDummyDir = fs.mkdtempSync('julia-dummy'); + fs.writeFileSync(path.join(tempDummyDir, 'dummy'), 'empty'); + juliaPath = yield tc.cacheDir(tempDummyDir, 'julia', version, arch); + yield installer.installJulia(juliaPath, versionInfo, version, arch); core.debug(`added Julia to cache: ${juliaPath}`); - // Remove temporary dir - fs.rmSync(juliaInstallationPath, { recursive: true }); + // Remove temporary dummy dir + fs.rmSync(tempDummyDir, { recursive: true }); } else { core.debug(`using cached version of Julia: ${juliaPath}`); diff --git a/src/installer.ts b/src/installer.ts index 83756d51..25aede59 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -198,7 +198,7 @@ export function getDownloadURL(fileInfo, version: string, arch: string): string return fileInfo.url } -export async function installJulia(versionInfo, version: string, arch: string): Promise { +export async function installJulia(dest: string, versionInfo, version: string, arch: string): Promise { // Download Julia const fileInfo = getFileInfo(versionInfo, version, arch) const downloadURL = getDownloadURL(fileInfo, version, arch) @@ -226,37 +226,35 @@ export async function installJulia(versionInfo, version: string, arch: string): core.debug('Skipping checksum check for nightly binaries.') } - const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`) - // Install it switch (osPlat) { case 'linux': // tc.extractTar doesn't support stripping components, so we have to call tar manually - await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]) - return tempInstallDir + await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]) + return dest case 'win32': if (fileInfo !== null && fileInfo.extension == 'exe') { if (version.endsWith('nightly') || semver.gtr(version, '1.3', {includePrerelease: true})) { // The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes - await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]) + await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]) } else { - await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]) + await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), dest)}" -NoNewWindow -Wait`]) } } else { // This is the more common path. Using .tar.gz is much faster - await exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${tempInstallDir}`]) + await exec.exec('powershell', ['-Command', `tar xf ${juliaDownloadPath} --strip-components=1 -C ${dest}`]) } - return tempInstallDir + return dest case 'darwin': if (fileInfo !== null && fileInfo.extension == 'dmg') { core.debug(`Support for .dmg files is deprecated and may be removed in a future release`) await exec.exec('hdiutil', ['attach', juliaDownloadPath]) - await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]) - return path.join(tempInstallDir, 'julia') + await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${dest}`]) + return path.join(dest, 'julia') } else { // tc.extractTar doesn't support stripping components, so we have to call tar manually - await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]) - return tempInstallDir + await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', dest]) + return dest } default: throw new Error(`Platform ${osPlat} is not supported`) diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 9982df38..91e14e62 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -69,14 +69,21 @@ async function run() { if (!juliaPath) { core.debug(`could not find Julia ${arch}/${version} in cache`) - const juliaInstallationPath = await installer.installJulia(versionInfo, version, arch) - // Add it to cache - juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch) + // we want julia to be installed with unmodified file mtimes + // but tc.cacheDir uses `cp` which destroys mtime + // and `tc` provides no API to get the tool directory alone + // so hack it by installing a dummy julia file then use the path it returns + // and extract the archives directly to that location + const tempDummyDir = fs.mkdtempSync('julia-dummy') + fs.writeFileSync(path.join(tempDummyDir, 'dummy'), 'empty'); + juliaPath = await tc.cacheDir(tempDummyDir, 'julia', version, arch) + await installer.installJulia(juliaPath, versionInfo, version, arch) + core.debug(`added Julia to cache: ${juliaPath}`) - // Remove temporary dir - fs.rmSync(juliaInstallationPath, {recursive: true}) + // Remove temporary dummy dir + fs.rmSync(tempDummyDir, {recursive: true}) } else { core.debug(`using cached version of Julia: ${juliaPath}`) } From a34a04a230639a57b5c6da3bf56dc1c525fbae51 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 00:40:40 -0500 Subject: [PATCH 02/15] [debug] demo stat --- .github/workflows/example-builds-defaultarch.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/example-builds-defaultarch.yml b/.github/workflows/example-builds-defaultarch.yml index a469afff..f62a1579 100644 --- a/.github/workflows/example-builds-defaultarch.yml +++ b/.github/workflows/example-builds-defaultarch.yml @@ -44,3 +44,4 @@ jobs: version: ${{ matrix.julia-version }} - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' + - run: julia -E 'stat(joinpath(dirname(Sys.BINDIR), "share", "julia", "stdlib", "v1.10", "MbedTLS_jll", "src", "MbedTLS_jll.jl"))' From 3714a58071d26f652dae7322a9a02ee6056554db Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 01:27:26 -0500 Subject: [PATCH 03/15] Revert "[debug] demo stat" This reverts commit a34a04a230639a57b5c6da3bf56dc1c525fbae51. --- .github/workflows/example-builds-defaultarch.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/example-builds-defaultarch.yml b/.github/workflows/example-builds-defaultarch.yml index f62a1579..a469afff 100644 --- a/.github/workflows/example-builds-defaultarch.yml +++ b/.github/workflows/example-builds-defaultarch.yml @@ -44,4 +44,3 @@ jobs: version: ${{ matrix.julia-version }} - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - - run: julia -E 'stat(joinpath(dirname(Sys.BINDIR), "share", "julia", "stdlib", "v1.10", "MbedTLS_jll", "src", "MbedTLS_jll.jl"))' From b677f384379fd954eb4c9ae7581a274da64129af Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 01:37:59 -0500 Subject: [PATCH 04/15] tidy --- lib/setup-julia.js | 3 +-- src/setup-julia.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/setup-julia.js b/lib/setup-julia.js index 4657e0b8..48b9ec96 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -96,8 +96,7 @@ function run() { // and `tc` provides no API to get the tool directory alone // so hack it by installing a dummy julia file then use the path it returns // and extract the archives directly to that location - const tempDummyDir = fs.mkdtempSync('julia-dummy'); - fs.writeFileSync(path.join(tempDummyDir, 'dummy'), 'empty'); + const tempDummyDir = fs.mkdtempSync('julia-dummy-'); juliaPath = yield tc.cacheDir(tempDummyDir, 'julia', version, arch); yield installer.installJulia(juliaPath, versionInfo, version, arch); core.debug(`added Julia to cache: ${juliaPath}`); diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 91e14e62..f535401b 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -75,8 +75,7 @@ async function run() { // and `tc` provides no API to get the tool directory alone // so hack it by installing a dummy julia file then use the path it returns // and extract the archives directly to that location - const tempDummyDir = fs.mkdtempSync('julia-dummy') - fs.writeFileSync(path.join(tempDummyDir, 'dummy'), 'empty'); + const tempDummyDir = fs.mkdtempSync('julia-dummy-') juliaPath = await tc.cacheDir(tempDummyDir, 'julia', version, arch) await installer.installJulia(juliaPath, versionInfo, version, arch) From 586048a629618b5e050bd8e0e2ff27b499b433a4 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 10:19:42 -0500 Subject: [PATCH 05/15] add test for julia install and mtime maintenance --- .github/workflows/example-builds-defaultarch.yml | 14 ++++++++++++++ .../example-builds-nightly-defaultarch.yml | 14 ++++++++++++++ .github/workflows/example-builds-nightly.yml | 14 ++++++++++++++ .github/workflows/example-builds.yml | 14 ++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/.github/workflows/example-builds-defaultarch.yml b/.github/workflows/example-builds-defaultarch.yml index a469afff..403698f3 100644 --- a/.github/workflows/example-builds-defaultarch.yml +++ b/.github/workflows/example-builds-defaultarch.yml @@ -44,3 +44,17 @@ jobs: version: ${{ matrix.julia-version }} - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' + - name: "Check that the correct julia is used and that archive mtimes are maintained" + run: | + if !occursin("hostedtoolcache", Sys.BINDIR) + error("the wrong julia is being used: $Sys.BINDIR") + end + if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip + using Pkg + src = pkgdir(Pkg, "src", "Pkg.jl") + # mtime is when it's compacted, ctime is when the file is extracted + if !<(mtime(src), ctime(src)) + error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") + end + end + shell: julia --startup-file=no --color=yes {0} diff --git a/.github/workflows/example-builds-nightly-defaultarch.yml b/.github/workflows/example-builds-nightly-defaultarch.yml index 1099f79e..03c88ab1 100644 --- a/.github/workflows/example-builds-nightly-defaultarch.yml +++ b/.github/workflows/example-builds-nightly-defaultarch.yml @@ -42,3 +42,17 @@ jobs: version: ${{ matrix.julia-version }} - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' + - name: "Check that the correct julia is used and that archive mtimes are maintained" + run: | + if !occursin("hostedtoolcache", Sys.BINDIR) + error("the wrong julia is being used: $Sys.BINDIR") + end + if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip + using Pkg + src = pkgdir(Pkg, "src", "Pkg.jl") + # mtime is when it's compacted, ctime is when the file is extracted + if !<(mtime(src), ctime(src)) + error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") + end + end + shell: julia --startup-file=no --color=yes {0} diff --git a/.github/workflows/example-builds-nightly.yml b/.github/workflows/example-builds-nightly.yml index 2ebee2f1..e7e48533 100644 --- a/.github/workflows/example-builds-nightly.yml +++ b/.github/workflows/example-builds-nightly.yml @@ -50,3 +50,17 @@ jobs: arch: ${{ matrix.julia-arch }} - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' + - name: "Check that the correct julia is used and that archive mtimes are maintained" + run: | + if !occursin("hostedtoolcache", Sys.BINDIR) + error("the wrong julia is being used: $Sys.BINDIR") + end + if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip + using Pkg + src = pkgdir(Pkg, "src", "Pkg.jl") + # mtime is when it's compacted, ctime is when the file is extracted + if !<(mtime(src), ctime(src)) + error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") + end + end + shell: julia --startup-file=no --color=yes {0} diff --git a/.github/workflows/example-builds.yml b/.github/workflows/example-builds.yml index c9402029..7f1ed931 100644 --- a/.github/workflows/example-builds.yml +++ b/.github/workflows/example-builds.yml @@ -50,3 +50,17 @@ jobs: arch: ${{ matrix.julia-arch }} - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' + - name: "Check that the correct julia is used and that archive mtimes are maintained" + run: | + if !occursin("hostedtoolcache", Sys.BINDIR) + error("the wrong julia is being used: $Sys.BINDIR") + end + if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip + using Pkg + src = pkgdir(Pkg, "src", "Pkg.jl") + # mtime is when it's compacted, ctime is when the file is extracted + if !<(mtime(src), ctime(src)) + error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") + end + end + shell: julia --startup-file=no --color=yes {0} From e6dda37bbdec11b1d33dd287ddc230d0a32a8566 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 10:46:26 -0500 Subject: [PATCH 06/15] add reference to PR Co-authored-by: Dilum Aluthge --- src/setup-julia.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/setup-julia.ts b/src/setup-julia.ts index f535401b..ece6eb38 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -70,6 +70,7 @@ async function run() { if (!juliaPath) { core.debug(`could not find Julia ${arch}/${version} in cache`) + // https://github.com/julia-actions/setup-julia/pull/196 // we want julia to be installed with unmodified file mtimes // but tc.cacheDir uses `cp` which destroys mtime // and `tc` provides no API to get the tool directory alone From 7759f63c0198577ece31b0b73d73f57411ae342f Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 10:48:09 -0500 Subject: [PATCH 07/15] Update setup-julia.js --- lib/setup-julia.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/setup-julia.js b/lib/setup-julia.js index 48b9ec96..feb6413f 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -91,6 +91,7 @@ function run() { juliaPath = tc.find('julia', version, arch); if (!juliaPath) { core.debug(`could not find Julia ${arch}/${version} in cache`); + // https://github.com/julia-actions/setup-julia/pull/196 // we want julia to be installed with unmodified file mtimes // but tc.cacheDir uses `cp` which destroys mtime // and `tc` provides no API to get the tool directory alone From c8bcd334095aeb7fd893d93d72bd1f9e821535e6 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 12:01:21 -0500 Subject: [PATCH 08/15] fixes/wording --- .github/workflows/example-builds-defaultarch.yml | 4 ++-- .github/workflows/example-builds-nightly-defaultarch.yml | 4 ++-- .github/workflows/example-builds-nightly.yml | 4 ++-- .github/workflows/example-builds.yml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/example-builds-defaultarch.yml b/.github/workflows/example-builds-defaultarch.yml index 403698f3..a616d431 100644 --- a/.github/workflows/example-builds-defaultarch.yml +++ b/.github/workflows/example-builds-defaultarch.yml @@ -47,12 +47,12 @@ jobs: - name: "Check that the correct julia is used and that archive mtimes are maintained" run: | if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $Sys.BINDIR") + error("the wrong julia is being used: $(Sys.BINDIR)") end if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip using Pkg src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compacted, ctime is when the file is extracted + # mtime is when it's compressed, ctime is when the file is extracted if !<(mtime(src), ctime(src)) error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") end diff --git a/.github/workflows/example-builds-nightly-defaultarch.yml b/.github/workflows/example-builds-nightly-defaultarch.yml index 03c88ab1..c31690c9 100644 --- a/.github/workflows/example-builds-nightly-defaultarch.yml +++ b/.github/workflows/example-builds-nightly-defaultarch.yml @@ -45,12 +45,12 @@ jobs: - name: "Check that the correct julia is used and that archive mtimes are maintained" run: | if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $Sys.BINDIR") + error("the wrong julia is being used: $(Sys.BINDIR)") end if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip using Pkg src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compacted, ctime is when the file is extracted + # mtime is when it's compressed, ctime is when the file is extracted if !<(mtime(src), ctime(src)) error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") end diff --git a/.github/workflows/example-builds-nightly.yml b/.github/workflows/example-builds-nightly.yml index e7e48533..26728c7a 100644 --- a/.github/workflows/example-builds-nightly.yml +++ b/.github/workflows/example-builds-nightly.yml @@ -53,12 +53,12 @@ jobs: - name: "Check that the correct julia is used and that archive mtimes are maintained" run: | if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $Sys.BINDIR") + error("the wrong julia is being used: $(Sys.BINDIR)") end if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip using Pkg src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compacted, ctime is when the file is extracted + # mtime is when it's compressed, ctime is when the file is extracted if !<(mtime(src), ctime(src)) error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") end diff --git a/.github/workflows/example-builds.yml b/.github/workflows/example-builds.yml index 7f1ed931..fb1e5d6a 100644 --- a/.github/workflows/example-builds.yml +++ b/.github/workflows/example-builds.yml @@ -53,12 +53,12 @@ jobs: - name: "Check that the correct julia is used and that archive mtimes are maintained" run: | if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $Sys.BINDIR") + error("the wrong julia is being used: $(Sys.BINDIR)") end if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip using Pkg src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compacted, ctime is when the file is extracted + # mtime is when it's compressed, ctime is when the file is extracted if !<(mtime(src), ctime(src)) error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") end From dcc55a3e224d3d8b07183865a550d194d25a3d83 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 4 Jan 2024 19:13:35 -0500 Subject: [PATCH 09/15] use a common test file --- .github/workflows/common-tests.jl | 11 +++++++++++ .github/workflows/example-builds-defaultarch.yml | 14 +------------- .../example-builds-nightly-defaultarch.yml | 14 +------------- .github/workflows/example-builds-nightly.yml | 14 +------------- .github/workflows/example-builds.yml | 14 +------------- 5 files changed, 15 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/common-tests.jl diff --git a/.github/workflows/common-tests.jl b/.github/workflows/common-tests.jl new file mode 100644 index 00000000..e1516a9b --- /dev/null +++ b/.github/workflows/common-tests.jl @@ -0,0 +1,11 @@ +if !occursin("hostedtoolcache", Sys.BINDIR) + error("the wrong julia is being used: $(Sys.BINDIR)") +end +if VERSION >= v"1.7.0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip + using Pkg + src = pkgdir(Pkg, "src", "Pkg.jl") + # mtime is when it's compressed, ctime is when the file is extracted + if !<(mtime(src), ctime(src)) + error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") + end +end diff --git a/.github/workflows/example-builds-defaultarch.yml b/.github/workflows/example-builds-defaultarch.yml index a616d431..f758f0ab 100644 --- a/.github/workflows/example-builds-defaultarch.yml +++ b/.github/workflows/example-builds-defaultarch.yml @@ -45,16 +45,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: | - if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $(Sys.BINDIR)") - end - if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip - using Pkg - src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compressed, ctime is when the file is extracted - if !<(mtime(src), ctime(src)) - error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") - end - end - shell: julia --startup-file=no --color=yes {0} + run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl diff --git a/.github/workflows/example-builds-nightly-defaultarch.yml b/.github/workflows/example-builds-nightly-defaultarch.yml index c31690c9..73d7adc4 100644 --- a/.github/workflows/example-builds-nightly-defaultarch.yml +++ b/.github/workflows/example-builds-nightly-defaultarch.yml @@ -43,16 +43,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: | - if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $(Sys.BINDIR)") - end - if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip - using Pkg - src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compressed, ctime is when the file is extracted - if !<(mtime(src), ctime(src)) - error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") - end - end - shell: julia --startup-file=no --color=yes {0} + run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl diff --git a/.github/workflows/example-builds-nightly.yml b/.github/workflows/example-builds-nightly.yml index 26728c7a..8157b195 100644 --- a/.github/workflows/example-builds-nightly.yml +++ b/.github/workflows/example-builds-nightly.yml @@ -51,16 +51,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: | - if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $(Sys.BINDIR)") - end - if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip - using Pkg - src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compressed, ctime is when the file is extracted - if !<(mtime(src), ctime(src)) - error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") - end - end - shell: julia --startup-file=no --color=yes {0} + run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl diff --git a/.github/workflows/example-builds.yml b/.github/workflows/example-builds.yml index fb1e5d6a..a8d639d4 100644 --- a/.github/workflows/example-builds.yml +++ b/.github/workflows/example-builds.yml @@ -51,16 +51,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: | - if !occursin("hostedtoolcache", Sys.BINDIR) - error("the wrong julia is being used: $(Sys.BINDIR)") - end - if VERSION > v"1.7.0-0" # pkgdir was introduced here, and before then mtime wasn't a problem so just skip - using Pkg - src = pkgdir(Pkg, "src", "Pkg.jl") - # mtime is when it's compressed, ctime is when the file is extracted - if !<(mtime(src), ctime(src)) - error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") - end - end - shell: julia --startup-file=no --color=yes {0} + run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl From 97dd8696d8093bcee05daf9f64b652cac4766e0c Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 5 Jan 2024 10:13:13 -0500 Subject: [PATCH 10/15] Apply suggestions from code review Co-authored-by: Curtis Vogt --- .github/workflows/common-tests.jl | 2 +- src/setup-julia.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/common-tests.jl b/.github/workflows/common-tests.jl index e1516a9b..45e2b82d 100644 --- a/.github/workflows/common-tests.jl +++ b/.github/workflows/common-tests.jl @@ -5,7 +5,7 @@ if VERSION >= v"1.7.0" # pkgdir was introduced here, and before then mtime wasn' using Pkg src = pkgdir(Pkg, "src", "Pkg.jl") # mtime is when it's compressed, ctime is when the file is extracted - if !<(mtime(src), ctime(src)) + if mtime(src) >= ctime(src) error("source mtime ($(mtime(src))) is not earlier than ctime ($(ctime(src)))") end end diff --git a/src/setup-julia.ts b/src/setup-julia.ts index ece6eb38..59be4b17 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -72,12 +72,12 @@ async function run() { // https://github.com/julia-actions/setup-julia/pull/196 // we want julia to be installed with unmodified file mtimes - // but tc.cacheDir uses `cp` which destroys mtime + // but `tc.cacheDir` uses `cp` internally which destroys mtime // and `tc` provides no API to get the tool directory alone - // so hack it by installing a dummy julia file then use the path it returns + // so hack it by installing a empty directory then use the path it returns // and extract the archives directly to that location - const tempDummyDir = fs.mkdtempSync('julia-dummy-') - juliaPath = await tc.cacheDir(tempDummyDir, 'julia', version, arch) + const emptyDir = fs.mkdtempSync('empty') + juliaPath = await tc.cacheDir(emptyDir, 'julia', version, arch) await installer.installJulia(juliaPath, versionInfo, version, arch) core.debug(`added Julia to cache: ${juliaPath}`) From b66d6131ac7176bdae8523a0bb2134264adb3d17 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 5 Jan 2024 10:14:23 -0500 Subject: [PATCH 11/15] move script --- .github/{workflows => scripts}/common-tests.jl | 0 .github/workflows/example-builds-defaultarch.yml | 2 +- .github/workflows/example-builds-nightly-defaultarch.yml | 2 +- .github/workflows/example-builds-nightly.yml | 2 +- .github/workflows/example-builds.yml | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename .github/{workflows => scripts}/common-tests.jl (100%) diff --git a/.github/workflows/common-tests.jl b/.github/scripts/common-tests.jl similarity index 100% rename from .github/workflows/common-tests.jl rename to .github/scripts/common-tests.jl diff --git a/.github/workflows/example-builds-defaultarch.yml b/.github/workflows/example-builds-defaultarch.yml index f758f0ab..23740c85 100644 --- a/.github/workflows/example-builds-defaultarch.yml +++ b/.github/workflows/example-builds-defaultarch.yml @@ -45,4 +45,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl + run: julia --startup-file=no --color=yes ./.github/scripts/common-tests.jl diff --git a/.github/workflows/example-builds-nightly-defaultarch.yml b/.github/workflows/example-builds-nightly-defaultarch.yml index 73d7adc4..2fb13938 100644 --- a/.github/workflows/example-builds-nightly-defaultarch.yml +++ b/.github/workflows/example-builds-nightly-defaultarch.yml @@ -43,4 +43,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl + run: julia --startup-file=no --color=yes ./.github/scripts/common-tests.jl diff --git a/.github/workflows/example-builds-nightly.yml b/.github/workflows/example-builds-nightly.yml index 8157b195..21190a65 100644 --- a/.github/workflows/example-builds-nightly.yml +++ b/.github/workflows/example-builds-nightly.yml @@ -51,4 +51,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl + run: julia --startup-file=no --color=yes ./.github/scripts/common-tests.jl diff --git a/.github/workflows/example-builds.yml b/.github/workflows/example-builds.yml index a8d639d4..0515b128 100644 --- a/.github/workflows/example-builds.yml +++ b/.github/workflows/example-builds.yml @@ -51,4 +51,4 @@ jobs: - run: julia --version - run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()' - name: "Check that the correct julia is used and that archive mtimes are maintained" - run: julia --startup-file=no --color=yes ./.github/workflows/common-tests.jl + run: julia --startup-file=no --color=yes ./.github/scripts/common-tests.jl From 34cd99c08978a2c70b945c881ca7886d0b7aeb80 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 5 Jan 2024 10:16:26 -0500 Subject: [PATCH 12/15] fixup --- lib/setup-julia.js | 12 ++++++------ src/setup-julia.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/setup-julia.js b/lib/setup-julia.js index feb6413f..84deb499 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -93,16 +93,16 @@ function run() { core.debug(`could not find Julia ${arch}/${version} in cache`); // https://github.com/julia-actions/setup-julia/pull/196 // we want julia to be installed with unmodified file mtimes - // but tc.cacheDir uses `cp` which destroys mtime + // but `tc.cacheDir` uses `cp` internally which destroys mtime // and `tc` provides no API to get the tool directory alone - // so hack it by installing a dummy julia file then use the path it returns + // so hack it by installing a empty directory then use the path it returns // and extract the archives directly to that location - const tempDummyDir = fs.mkdtempSync('julia-dummy-'); - juliaPath = yield tc.cacheDir(tempDummyDir, 'julia', version, arch); + const emptyDir = fs.mkdtempSync('empty'); + juliaPath = yield tc.cacheDir(emptyDir, 'julia', version, arch); yield installer.installJulia(juliaPath, versionInfo, version, arch); core.debug(`added Julia to cache: ${juliaPath}`); - // Remove temporary dummy dir - fs.rmSync(tempDummyDir, { recursive: true }); + // Remove empty dir + fs.rmSync(emptyDir); } else { core.debug(`using cached version of Julia: ${juliaPath}`); diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 59be4b17..4c56bf2a 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -82,8 +82,8 @@ async function run() { core.debug(`added Julia to cache: ${juliaPath}`) - // Remove temporary dummy dir - fs.rmSync(tempDummyDir, {recursive: true}) + // Remove empty dir + fs.rmSync(emptyDir) } else { core.debug(`using cached version of Julia: ${juliaPath}`) } From 9ffeeeb046d46f248220d570e939b17fb6481326 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 5 Jan 2024 10:22:04 -0500 Subject: [PATCH 13/15] tryfix --- src/setup-julia.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 4c56bf2a..2968c20a 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -82,8 +82,8 @@ async function run() { core.debug(`added Julia to cache: ${juliaPath}`) - // Remove empty dir - fs.rmSync(emptyDir) + // Remove empty dir. Has to be recursive as it's a dir, even though it's empty + fs.rmSync(emptyDir, { recursive: true }) } else { core.debug(`using cached version of Julia: ${juliaPath}`) } From 4949fc05defa9021c8938419611cf64accc6e417 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 5 Jan 2024 10:26:56 -0500 Subject: [PATCH 14/15] use rmdirSync --- src/setup-julia.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 2968c20a..1f309232 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -82,8 +82,8 @@ async function run() { core.debug(`added Julia to cache: ${juliaPath}`) - // Remove empty dir. Has to be recursive as it's a dir, even though it's empty - fs.rmSync(emptyDir, { recursive: true }) + // Remove empty dir + fs.rmdirSync(emptyDir) } else { core.debug(`using cached version of Julia: ${juliaPath}`) } From 71c8c6a3cb233d1d735f75b921fc58cb55ed0fd3 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 5 Jan 2024 10:27:40 -0500 Subject: [PATCH 15/15] npm run build --- lib/setup-julia.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup-julia.js b/lib/setup-julia.js index 84deb499..2b967b3b 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -102,7 +102,7 @@ function run() { yield installer.installJulia(juliaPath, versionInfo, version, arch); core.debug(`added Julia to cache: ${juliaPath}`); // Remove empty dir - fs.rmSync(emptyDir); + fs.rmdirSync(emptyDir); } else { core.debug(`using cached version of Julia: ${juliaPath}`);