Skip to content
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
15 changes: 15 additions & 0 deletions .github/actions/setup-bazel/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ runs:
sudo chmod 0440 /etc/sudoers.d/tailscale-ci-network
sudo visudo -cf /etc/sudoers.d/tailscale-ci-network

- name: Read the hosted Mac's Ethernet resolver settings
id: macos-dns
if: runner.os == 'macOS' && inputs.tailscale-client-id != ''
shell: bash
run: python3 "$GITHUB_ACTION_PATH/macos_dns.py" read >> "$GITHUB_OUTPUT"

- name: Connect to the private Bazel fleet
id: tailscale
if: inputs.tailscale-client-id != ''
Expand All @@ -207,6 +213,15 @@ runs:
args: --accept-dns=false
ping: ubuntu-main

# The pinned Tailscale action explicitly reconfigures Ethernet when MagicDNS
# is enabled on macOS, even when tailscale up receives --accept-dns=false.
- name: Restore the hosted Mac's Ethernet resolver settings
if: always() && steps.macos-dns.outcome == 'success'
shell: bash
env:
ETHERNET_DNS: ${{ steps.macos-dns.outputs.settings }}
run: python3 "$GITHUB_ACTION_PATH/macos_dns.py" restore

- name: Select private executor or hosted execution
id: fleet
shell: bash
Expand Down
42 changes: 42 additions & 0 deletions .github/actions/setup-bazel/macos_dns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Preserve the Ethernet settings changed by the Tailscale macOS action."""

import json
import os
import subprocess
import sys


# networksetup returns one line per entry, or a sentence when DHCP supplies it.
SETTINGS = {"dnsservers": "DNS Servers", "searchdomains": "Search Domains"}


def read_settings(service):
settings = {}
for option, label in SETTINGS.items():
value = subprocess.check_output(
["networksetup", "-get" + option, service],
text=True,
env={**os.environ, "LC_ALL": "C"},
).strip()
if not value:
raise ValueError(f"networksetup returned no result for {option}")
automatic = f"There aren't any {label} set on {service}."
settings[option] = [] if value == automatic else value.splitlines()
return settings


def restore_settings(service, settings):
for option in SETTINGS:
subprocess.run(
["networksetup", "-set" + option, service, *(settings[option] or ["Empty"])],
check=True,
)
Comment on lines +28 to +33

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Resolver restoration lacks regression coverage

Changes to restore_settings can break automatic or explicit DNS restoration without failing a checked-in test. The new reader and writer have no committed tests.

Learn more

This shared CI action reads macOS resolver settings before Tailscale enrollment and restores them afterward. Both behaviors are new, but no committed test exercises the parser or the networksetup commands. The repository requires test coverage for new behavior. Local manual verification does not catch later changes to the action.

Example: Given automatic DNS and two explicit search domains, a mock networksetup can return the automatic DNS sentence and two domain lines. A test can check that restoration passes Empty for DNS and both original domains in order.

Recommended fix: Add checked-in tests for read_settings and restore_settings using mocked subprocess results. Cover automatic values, ordered explicit lists, and failed networksetup commands; run them through a maintained test target.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.



if __name__ == "__main__":
if sys.argv[1:] == ["read"]:
print("settings=" + json.dumps(read_settings("Ethernet")))
elif sys.argv[1:] == ["restore"]:
restore_settings("Ethernet", json.loads(os.environ["ETHERNET_DNS"]))
else:
sys.exit("expected read or restore")
Loading