DEBUG with VS Code instead #1587
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
name: CI | |
on: [push, pull_request] | |
env: | |
DEVELOPER: 1 | |
# If more than one workflow run is triggered for the very same commit hash | |
# (which happens when multiple branches pointing to the same commit), only | |
# the first one is allowed to run, the second will be kept in the "queued" | |
# state. This allows a successful completion of the first run to be reused | |
# in the second run via the `skip-if-redundant` logic in the `config` job. | |
# | |
# The only caveat is that if a workflow run is triggered for the same commit | |
# hash that another run is already being held, that latter run will be | |
# canceled. For more details about the `concurrency` attribute, see: | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency | |
concurrency: | |
group: ${{ github.sha }} | |
jobs: | |
windows-test: | |
name: win test | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
n: | |
- nr: "-13" | |
run: 7238908991 | |
concurrency: | |
group: windows-test-${{ matrix.n.nr }}-${{ github.ref }} | |
steps: | |
- name: start VS Code tunnel | |
shell: bash | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
# First get the current user's GPG key | |
gh api users/${{ github.actor }}/gpg_keys --jq '.[0].raw_key' | | |
gpg --import >/tmp/gpg.import 2>&1 && | |
GPGKEY="$(sed -n 's/^gpg: key \([^:]*\).*/\1/p' /tmp/gpg.import)" && | |
test -n "$GPGKEY" && | |
echo "Using GPG key $GPGKEY" || { | |
echo "::error::could not get user's GPG key" >&2 | |
exit 1 | |
} | |
curl -Lo /tmp/vscode-cli.zip 'https://code.visualstudio.com/sha/download?build=stable&os=cli-win32-x64' && | |
unzip -p /tmp/vscode-cli.zip code.exe >/tmp/vscode-cli.exe && | |
name="$(echo "$GITHUB_JOB-$GITHUB_RUN_ID" | | |
sed -e 's/[^A-Za-z0-9_]/-/g' -e 's/--*/-/g' -e 's/^-*//' -e 's/^\(.\{1,20\}\).*/\1/')" | |
echo "::notice::Starting a tunnel with name '$name'" >&2 | |
/tmp/vscode-cli.exe tunnel --accept-server-license-terms --name "$name" >/tmp/vscode-tunnel.out & | |
display_message () { | |
printf '%s\n' \ | |
"Please decrypt the output of 'code tunnel' by calling these commands" \ | |
'' \ | |
'cat <<EOF >/tmp/vscode.gpg &&' \ | |
"$(gpg --batch --trust-model always --recipient "$GPGKEY" \ | |
--pinentry-mode=loopback --encrypt --armor </tmp/vscode-tunnel.out)" \ | |
'EOF' \ | |
'gpg --decrypt /tmp/vscode.gpg' | |
} | |
while true | |
do | |
sleep 15 | |
# Make sure the contents of vscode-tunnel.out is not displayed, as it contains the secret device code and then the URL! | |
if grep -q "Open this link in your browser" /tmp/vscode-tunnel.out >/dev/null 2>&1 | |
then | |
echo "::notice::Tunnel is ready to go" | |
display_message | |
exit 0 | |
# Technically, the device code is not a secret. But it will grant | |
# access _to the tunnel_, i.e. to the machine running the current | |
# GitHub workflow job, including all the code and the secrets... | |
elif grep -q "To grant access to the server" /tmp/vscode-tunnel.out >/dev/null 2>&1 | |
then | |
echo "::notice::Tunnel needs to be granted access" | |
display_message | |
fi | |
done | |
- name: reuse `windows-artifacts` | |
shell: bash | |
run: | | |
run_id=7069719923 && | |
name=windows-artifacts && | |
curl -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \ | |
-L https://api.github.com/repos/${{github.repository}}/actions/runs/$run_id/artifacts | | |
jq -r '.artifacts[] | select(.name | test("'$name'")) | [.name, .archive_download_url] | @tsv' | | |
tr -d '\r' | | |
while read name url | |
do | |
echo "$name" | |
curl -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \ | |
-#sLo /tmp/"$name".zip "$url" && | |
unzip -q /tmp/"$name".zip | |
done | |
- name: extract tracked files and build artifacts | |
shell: bash | |
run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz | |
- name: do use current versions of a couple of files | |
shell: bash | |
run: | | |
# these have changed since the run whose artifacts we're reusing | |
for p in ci/lib.sh t/Makefile | |
do | |
curl -Lo $p ${{ github.server_url }}/${{ github.repository }}/raw/${{ github.sha }}/$p || | |
exit 1 | |
done | |
- uses: git-for-windows/setup-git-for-windows-sdk@v1 | |
- name: replace the MSYS2 runtime | |
shell: powershell | |
run: | | |
$headers = @{ Authorization = "token ${{ secrets.GITHUB_TOKEN }}" } | |
$run_url = "https://api.github.com/repos/dscho/Cygwin-msys2-fork/actions/runs/${{ matrix.n.run }}/artifacts" | |
$run = ((Invoke-WebRequest -Headers $headers $run_url).content | ConvertFrom-JSON) | |
$zip_url = $run.artifacts.archive_download_url | |
Invoke-WebRequest -Headers $headers $zip_url -outfile "install.zip" | |
Expand-Archive -Force -DestinationPath D:/git-sdk-64-minimal install.zip | |
Remove-Item install.zip | |
- name: test | |
id: test | |
shell: bash | |
timeout-minutes: 240 | |
run: . /etc/profile && env >/tmp/env.txt && set >/tmp/set.txt && ci/run-test-slice.sh 0 1 | |
- name: handle timed-out tests | |
if: failure() && steps.test.outcome == 'failure' && env.FAILED_TEST_ARTIFACTS == '' | |
shell: bash | |
run: . /etc/profile && . ci/lib.sh && { handle_failed_tests || test $? = 1; } | |
- name: print test failures | |
if: failure() && env.FAILED_TEST_ARTIFACTS != '' | |
shell: bash | |
run: ci/print-test-failures.sh | |
- name: Upload failed/timed-out tests' directories | |
if: failure() && env.FAILED_TEST_ARTIFACTS != '' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: failed-tests-windows | |
path: ${{env.FAILED_TEST_ARTIFACTS}} | |
- name: wait for VSCode tunnel to be done | |
# wait for the user to terminate the tunnel, even if the job failed, but not if it was canceled | |
if: success() || failure() | |
shell: bash | |
run: | | |
while test -f /tmp/vscode-cli.exe | |
do | |
case "$(/tmp/vscode-cli.exe tunnel status)" in | |
*"no tunnel process is currently running"*) exit 0;; | |
esac | |
echo '::notice::Waiting for tunnel to be terminated' | |
echo '(please run `/tmp/vscode-cli.exe tunnel kill` in the integrated terminal)' | |
sleep 15 | |
done | |
- name: unregister VSCode tunnel | |
# unregister the tunnel, even if the job was canceled | |
if: always() | |
shell: bash | |
run: /tmp/vscode-cli.exe tunnel unregister |