fix: update workflow fixes
This commit is contained in:
6 files changed
+92
-5
No files matched your search
@@ -22,9 +22,10 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-dependencies:
|
update-dependencies:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
outputs:
|
outputs:
|
||||||
has_changes: ${{ steps.changes.outputs.has_changes }}
|
has_changes: ${{ steps.changes.outputs.has_changes }}
|
||||||
|
checks_failed: ${{ steps.checks.outputs.failed }}
|
||||||
steps:
|
steps:
|
||||||
# No token left in .git/config for the steps that run fetched code (flake updates,
|
# No token left in .git/config for the steps that run fetched code (flake updates,
|
||||||
# update-pins.sh, nix builds); create-pull-request authenticates on its own.
|
# update-pins.sh, nix builds); create-pull-request authenticates on its own.
|
||||||
@@ -86,15 +87,33 @@ jobs:
|
|||||||
mapfile -t attrs < <(scripts/update-pins.sh --attrs)
|
mapfile -t attrs < <(scripts/update-pins.sh --attrs)
|
||||||
nix build --no-link "${attrs[@]}"
|
nix build --no-link "${attrs[@]}"
|
||||||
|
|
||||||
|
# A failing check does not hold the update back: the pull request opens as a draft
|
||||||
|
# naming the failures, and the run still ends red (open-pull-request's last step).
|
||||||
- name: Run flake checks
|
- name: Run flake checks
|
||||||
|
id: checks
|
||||||
if: steps.changes.outputs.has_changes == 'true'
|
if: steps.changes.outputs.has_changes == 'true'
|
||||||
run: nix flake check --print-build-logs
|
run: |
|
||||||
|
set -uo pipefail
|
||||||
|
log="$RUNNER_TEMP/flake-check.log"
|
||||||
|
if nix flake check --keep-going --print-build-logs 2>&1 | tee "$log"; then
|
||||||
|
echo "failed=false" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "failed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
# The check attributes nix marks failed; else the derivations it could not build.
|
||||||
|
{
|
||||||
|
grep -oE '❌ checks\.[^[:space:]]+' "$log" | sed 's/^❌ //' ||
|
||||||
|
grep -oE "Cannot build '/nix/store/[a-z0-9]{32}-[^']+\.drv'" "$log" |
|
||||||
|
sed -E "s|^.*/[a-z0-9]{32}-||; s|\.drv'$||"
|
||||||
|
} | sort -u > "$RUNNER_TEMP/failed-checks.txt" || true
|
||||||
|
|
||||||
- name: Compose pull request body
|
- name: Compose pull request body
|
||||||
if: steps.changes.outputs.has_changes == 'true'
|
if: steps.changes.outputs.has_changes == 'true'
|
||||||
env:
|
env:
|
||||||
SHOULD_UPDATE_NIXPKGS: ${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}
|
SHOULD_UPDATE_NIXPKGS: ${{ steps.nixpkgs_gate.outputs.should_update_nixpkgs }}
|
||||||
CHANGED_WATCH_ATTRS: ${{ steps.nixpkgs_gate.outputs.nixpkgs_changed_watch_attrs }}
|
CHANGED_WATCH_ATTRS: ${{ steps.nixpkgs_gate.outputs.nixpkgs_changed_watch_attrs }}
|
||||||
|
CHECKS_FAILED: ${{ steps.checks.outputs.failed }}
|
||||||
|
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
{
|
{
|
||||||
@@ -114,6 +133,18 @@ jobs:
|
|||||||
echo "- changed watched attrs: \`$CHANGED_WATCH_ATTRS\`"
|
echo "- changed watched attrs: \`$CHANGED_WATCH_ATTRS\`"
|
||||||
echo "- zapret: refreshed every run"
|
echo "- zapret: refreshed every run"
|
||||||
echo
|
echo
|
||||||
|
echo "### Flake checks"
|
||||||
|
if [[ "$CHECKS_FAILED" == "true" ]]; then
|
||||||
|
echo "Failed, so this pull request is a draft ([run log]($RUN_URL)):"
|
||||||
|
if [[ -s "$RUNNER_TEMP/failed-checks.txt" ]]; then
|
||||||
|
while IFS= read -r check; do echo "- \`$check\`"; done < "$RUNNER_TEMP/failed-checks.txt"
|
||||||
|
else
|
||||||
|
echo "- no failing check named in the log; see the run"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "- all passed"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
echo '```'
|
echo '```'
|
||||||
git diff --stat
|
git diff --stat
|
||||||
echo '```'
|
echo '```'
|
||||||
@@ -146,7 +177,7 @@ jobs:
|
|||||||
open-pull-request:
|
open-pull-request:
|
||||||
needs: update-dependencies
|
needs: update-dependencies
|
||||||
if: needs.update-dependencies.outputs.has_changes == 'true'
|
if: needs.update-dependencies.outputs.has_changes == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
@@ -175,8 +206,11 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Create or update pull request
|
- name: Create or update pull request
|
||||||
|
id: pr
|
||||||
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
||||||
with:
|
with:
|
||||||
|
# always-true also turns an open pull request back into a draft.
|
||||||
|
draft: ${{ needs.update-dependencies.outputs.checks_failed == 'true' && 'always-true' || 'false' }}
|
||||||
branch: ci/update-dependencies
|
branch: ci/update-dependencies
|
||||||
delete-branch: false
|
delete-branch: false
|
||||||
add-paths: |
|
add-paths: |
|
||||||
@@ -189,3 +223,23 @@ jobs:
|
|||||||
labels: |
|
labels: |
|
||||||
dependencies
|
dependencies
|
||||||
nix
|
nix
|
||||||
|
|
||||||
|
# draft: false leaves an existing draft alone; once the checks pass, mark it ready.
|
||||||
|
- name: Mark the pull request ready for review
|
||||||
|
if: needs.update-dependencies.outputs.checks_failed != 'true' && steps.pr.outputs.pull-request-operation == 'updated'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
PR_NUMBER: ${{ steps.pr.outputs.pull-request-number }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [[ "$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json isDraft --jq .isDraft)" == "true" ]]; then
|
||||||
|
gh pr ready "$PR_NUMBER" --repo "$GITHUB_REPOSITORY"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Fail the run on failed checks
|
||||||
|
if: needs.update-dependencies.outputs.checks_failed == 'true'
|
||||||
|
env:
|
||||||
|
PR_URL: ${{ steps.pr.outputs.pull-request-url }}
|
||||||
|
run: |
|
||||||
|
echo "::error::Flake checks failed; the update is a draft pull request: $PR_URL"
|
||||||
|
exit 1
|
||||||
@@ -176,7 +176,9 @@ pkgs.testers.runNixOSTest {
|
|||||||
server.succeed("ip link show awgi-home")
|
server.succeed("ip link show awgi-home")
|
||||||
server.succeed("ip link show awgi-roam")
|
server.succeed("ip link show awgi-roam")
|
||||||
server.succeed("nft list table inet proxy_suite_awg_inbounds")
|
server.succeed("nft list table inet proxy_suite_awg_inbounds")
|
||||||
server.succeed("test $(jq '[.[] | select(.type == \"amneziawg\")] | length' /run/proxy-suite-inbounds/links.json) = 4")
|
# The unit is active once its start script runs; it writes the links just before
|
||||||
|
# XRay's exec, so they may not be there yet.
|
||||||
|
server.wait_until_succeeds("test \"$(jq '[.[] | select(.type == \"amneziawg\")] | length' /run/proxy-suite-inbounds/links.json)\" = 4", timeout=60)
|
||||||
server.succeed("test -n \"$(proxy-ctl inbounds link home phone --config --qr)\"")
|
server.succeed("test -n \"$(proxy-ctl inbounds link home phone --config --qr)\"")
|
||||||
import_profiles(alice, "phone", "tablet")
|
import_profiles(alice, "phone", "tablet")
|
||||||
import_profiles(bob, "laptop", "watch")
|
import_profiles(bob, "laptop", "watch")
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ let
|
|||||||
# Fixed so the client can be configured against it at build time. Real
|
# Fixed so the client can be configured against it at build time. Real
|
||||||
# deployments keep these in a secret manager.
|
# deployments keep these in a secret manager.
|
||||||
uuid = "b831381d-6324-4d53-ad4f-8cda48b30811";
|
uuid = "b831381d-6324-4d53-ad4f-8cda48b30811";
|
||||||
ssPassword = "dGhpcy1pcy1hLTE2Ynl0ZS1rZXk=";
|
# Base64 of exactly 16 bytes, the 2022-blake3-aes-128-gcm key length (XRay 26.9.30 refuses others).
|
||||||
|
ssPassword = "dGhpcy1pcy0xNi1ieXRlcw==";
|
||||||
# Public addresses: blockPrivate would refuse the origin on a private one.
|
# Public addresses: blockPrivate would refuse the origin on a private one.
|
||||||
serverAddress = "11.0.0.1";
|
serverAddress = "11.0.0.1";
|
||||||
# XRay refuses plain VLESS to a public IP, so the client dials a private one.
|
# XRay refuses plain VLESS to a public IP, so the client dials a private one.
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ let
|
|||||||
websockets
|
websockets
|
||||||
requests
|
requests
|
||||||
cryptography
|
cryptography
|
||||||
|
# proxy/cf_h2.py since v1.11: httpx with its HTTP/2 extra (h2), CA bundle from certifi.
|
||||||
|
httpx
|
||||||
|
h2
|
||||||
|
certifi
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import os
|
|||||||
import secrets
|
import secrets
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
|
import inbound_runtime
|
||||||
from awg_inbound import client_entries
|
from awg_inbound import client_entries
|
||||||
from proxy_parsing import build_outbound
|
from proxy_parsing import build_outbound
|
||||||
|
|
||||||
@@ -222,10 +223,22 @@ def render_xray_inbound(listener: dict) -> dict:
|
|||||||
if len(users) == 1:
|
if len(users) == 1:
|
||||||
settings["password"] = _user_secret(users[0], listener_type, tag)
|
settings["password"] = _user_secret(users[0], listener_type, tag)
|
||||||
settings["email"] = users[0].get("name") or f"{tag}-0"
|
settings["email"] = users[0].get("name") or f"{tag}-0"
|
||||||
|
keys = [(settings["email"], settings["password"])]
|
||||||
else:
|
else:
|
||||||
# Multi-user is 2022-blake3-aes only: the server key, then one key per user.
|
# Multi-user is 2022-blake3-aes only: the server key, then one key per user.
|
||||||
settings["password"] = _server_secret(listener, tag)
|
settings["password"] = _server_secret(listener, tag)
|
||||||
settings["clients"] = _clients(listener, tag)
|
settings["clients"] = _clients(listener, tag)
|
||||||
|
keys = [("server", settings["password"])] + [(c["email"], c["password"]) for c in settings["clients"]]
|
||||||
|
# Keys from files are only seen here; XRay refuses one of another length with a bare
|
||||||
|
# "bad key" and does not start at all.
|
||||||
|
method = listener["method"]
|
||||||
|
if method in inbound_runtime.SS2022_KEY_BYTES:
|
||||||
|
for name, key in keys:
|
||||||
|
if not inbound_runtime._ss2022_key_ok(key, method):
|
||||||
|
raise ValueError(
|
||||||
|
f"listener '{tag}': the {name} key is not base64 of "
|
||||||
|
f"{inbound_runtime.SS2022_KEY_BYTES[method]} bytes, as {method} needs"
|
||||||
|
)
|
||||||
elif listener_type in ("socks", "http"):
|
elif listener_type in ("socks", "http"):
|
||||||
settings = {"auth": "password", "accounts": _accounts(listener, tag)}
|
settings = {"auth": "password", "accounts": _accounts(listener, tag)}
|
||||||
if listener_type == "socks":
|
if listener_type == "socks":
|
||||||
|
|||||||
@@ -242,6 +242,19 @@ class RenderInboundTests(unittest.TestCase):
|
|||||||
with self.assertRaisesRegex(ValueError, "no server password"):
|
with self.assertRaisesRegex(ValueError, "no server password"):
|
||||||
render_xray_inbound(multi_user_shadowsocks(serverPassword=None))
|
render_xray_inbound(multi_user_shadowsocks(serverPassword=None))
|
||||||
|
|
||||||
|
def test_shadowsocks_2022_key_of_wrong_length_is_rejected(self):
|
||||||
|
# 20 bytes for a 16-byte method: XRay would fail its whole start on it.
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
key_path = os.path.join(tmp, "password")
|
||||||
|
with open(key_path, "w", encoding="utf-8") as handle:
|
||||||
|
handle.write("dGhpcy1pcy1hLTE2Ynl0ZS1rZXk=\n")
|
||||||
|
with self.assertRaisesRegex(ValueError, "the ss key is not base64 of 16 bytes"):
|
||||||
|
render_xray_inbound(
|
||||||
|
listener(type="shadowsocks", users=[{"name": "ss", "password": None, "passwordFile": key_path}])
|
||||||
|
)
|
||||||
|
with self.assertRaisesRegex(ValueError, "the server key is not base64 of 16 bytes"):
|
||||||
|
render_xray_inbound(multi_user_shadowsocks(serverPassword="c2hvcnQ="))
|
||||||
|
|
||||||
def test_socks_accounts_and_udp(self):
|
def test_socks_accounts_and_udp(self):
|
||||||
ib = render_xray_inbound(
|
ib = render_xray_inbound(
|
||||||
listener(type="socks", users=[{"name": "me", "password": "pw", "passwordFile": None}])
|
listener(type="socks", users=[{"name": "me", "password": "pw", "passwordFile": None}])
|
||||||
|
|||||||
Reference in new issue
Block a user