Skip to content

open-pr: avoid using system curl (because it can't do TLS v1.3) #24

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 4 commits into from
Feb 6, 2023
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
85 changes: 55 additions & 30 deletions .github/workflows/open-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,39 +74,64 @@ jobs:

core.setSecret(accessToken)
core.setOutput('token', accessToken)
- name: set up partial Git for Windows SDK
uses: git-for-windows/setup-git-for-windows-sdk@v1
- name: initialize bare SDK clone
id: clone-g4w-sdk
shell: bash
run: |
git clone --bare --depth=1 --single-branch --branch=main --filter=blob:none \
https://github.com/git-for-windows/git-sdk-64 .tmp &&
echo "rev=$(git -C .tmp rev-parse HEAD)" >>$GITHUB_OUTPUT
- name: restore cached git-sdk-64 subset
id: restore-g4w-sdk
uses: actions/cache/restore@v3
env:
cache-name: cache-g4w-sdk
with:
flavor: minimal
- name: download files necessary for `updpkgsums` to work
path: .sdk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does the cache action save the cache?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the post checkout step that is implied by actions/cache.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not ideal. It's caching the .sdk directory after we already cloned the target repo, which could cause collisions when opening PRs for multiple packages in the same repo. Maybe we should use actions/cache/restore and actions/cache/save to explicitely create the cache after the sparse checkout?

Copy link
Member Author

@dscho dscho Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point.

I changed it. To prove that it works, I ran a dry-run that did not find a cached artifact and successfully cached it, followed by a dry-run that found the cache and successfully avoided re-checking out and re-caching it.

key: g4w-sdk-${{ steps.clone-g4w-sdk.outputs.rev }}
- name: check out git-sdk-64 subset
if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
shell: bash
env:
GIT_CONFIG_PARAMETERS: "'checkout.workers=56'"
run: |
for p in \
/etc/makepkg.conf \
/usr/bin/gettext.exe \
/usr/bin/makepkg \
/usr/bin/nproc.exe \
/usr/bin/pacman.exe \
/usr/bin/sha256sum.exe \
/usr/bin/updpkgsums
do
curl -sLo $p https://github.com/git-for-windows/git-sdk-64/raw/HEAD$p || exit 1
done &&
for p in /usr/share/makepkg
do
b=${p##*/} &&
d=${p%/$b} &&
if test "z$b" = "z$d"
then
d=
fi &&
tree=$(curl -s https://api.github.com/repos/git-for-windows/git-sdk-64/git/trees/main:${d#/} |
jq -r '.tree[] | select(.path | test("^'$b'$")) | .sha') &&
mkdir -p $p &&
curl -sL https://github.com/git-for-windows/git-sdk-64/tarball/$tree |
tar --strip-components=1 -C $p -xzvf - || exit 1
done &&
ln -s "${COMSPEC%cmd.exe}curl.exe" /usr/bin/
git -C .tmp config extensions.worktreeConfig true &&
git -C .tmp worktree add --no-checkout --detach "$PWD/.sdk" &&
cd .sdk &&
git config --worktree core.sparseCheckout true &&
git config --worktree core.bare false &&
sparse="$(git rev-parse --git-path info/sparse-checkout)" &&
mkdir -p "${sparse%/*}" &&
git show HEAD:.sparse/minimal-sdk >"$sparse" &&
cat >>"$sparse" <<-EOF &&
/etc/makepkg.conf
/usr/bin/gettext.exe
/usr/bin/makepkg
/usr/bin/nproc.exe
/usr/bin/pacman.exe
/usr/bin/sha256sum.exe
/usr/bin/updpkgsums
/usr/share/makepkg/
/mingw64/bin/curl.exe
EOF
git checkout -- &&

# makepkg/updpkgsums expects `curl` to be present in `/usr/bin/`
printf '#!/bin/sh\n\nexec /mingw64/bin/curl.exe "$@"' >usr/bin/curl &&

# add the SDK directories to the `PATH`
cygpath -aw "usr/bin/core_perl" >>$GITHUB_PATH &&
cygpath -aw "usr/bin" >>$GITHUB_PATH &&
cygpath -aw "mingw64/bin" >>$GITHUB_PATH &&
echo "MSYSTEM=MINGW64" >>$GITHUB_ENV
- name: cache git-sdk-64 subset
if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v3
env:
cache-name: cache-g4w-sdk
with:
path: .sdk
key: g4w-sdk-${{ steps.clone-g4w-sdk.outputs.rev }}
- name: Clone ${{ env.REPO }}
shell: bash
run: |
Expand Down
19 changes: 19 additions & 0 deletions update-scripts/version/openssh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node

// The `openssh` version looks like this: 9.1p1. But the website calls it 9.1_P1.
// Let's auto-translate that.

(async () => {
const version = process.argv[2].replace(/_P/, 'p')

const fs = require('fs')
const lines = fs.readFileSync('PKGBUILD').toString('utf-8').split(/\r?\n/)
lines.forEach((line, i) => {
if ((match = line.match(/^(\s*pkgver=)\S+/))) {
lines[i] = `${match[1]}${version}`
} else if ((match = line.match(/^(\s*pkgrel=)\S+/))) {
lines[i] = `${match[1]}1`
}
})
fs.writeFileSync('PKGBUILD', lines.join('\n'))
})().catch(console.log)