Skip to content
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

🐛 fix: fix error when ~/.config/dns-manager does not exist #3

Merged
merged 2 commits into from
Nov 4, 2024
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
10 changes: 4 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target-version: [py310, py311, py312]
concurrency: release
permissions:
id-token: write
Expand All @@ -28,9 +25,10 @@ jobs:
- name: Install the latest version of uv 📦
uses: astral-sh/setup-uv@v2
- name: Build distributions 📦
env:
PYFUTURE_TARGET: ${{ matrix.target-version }}
run: uv build
run: |
PYFUTURE_TARGET=py312 uv build --wheel
PYFUTURE_TARGET=py311 uv build --wheel
PYFUTURE_TARGET=py310 uv build --wheel
- name: Publish package distributions to PyPI 🚀
if: steps.release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ permissions:

jobs:
coverage:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout 📦
uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Install just 📦
uses: extractions/setup-just@v2
- name: Install the latest version of uv 📦
uses: astral-sh/setup-uv@v3
- name: Install Python 📦
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install just 📦
uses: extractions/setup-just@v2
- name: Install dependencies 📦
run: just install
- run: |
uv run dnsm update examples/simple.toml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TENCENTCLOUD_SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }}
TENCENTCLOUD_SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY }}
LEXICON_CLOUDFLARE_AUTH_TOKEN: ${{ secrets.LEXICON_CLOUDFLARE_AUTH_TOKEN }}
- name: Run tests and benchmarks ✅
uses: CodSpeedHQ/action@v3
env:
Expand All @@ -33,9 +38,9 @@ jobs:
with:
run: just test
- name: Upload coverage reports to Codecov 🚀
uses: codecov/codecov-action@v4-beta
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: Pyfuture
flags: dns-manager
plugins: pycoverage,compress-pycoverage
21 changes: 12 additions & 9 deletions dns_manager/setter/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,18 @@ def update_dns(self, remove_unmanaged: bool = False):
records.append((subdomain, record.value))
logger.warning(f"([red]🔓 Unmanaged[/]) {record}")
path = Path("~/.config/dns-manager/unmanaged.json")
save_config(
path,
Config(
domain=self.domain,
setter_name=self.setter_name,
records=records,
).model_dump(),
)
logger.info(f"Unmanaged records saved to [bold purple]{path}[/].")
try:
save_config(
path,
Config(
domain=self.domain,
setter_name=self.setter_name,
records=records,
).model_dump(),
)
logger.info(f"Unmanaged records saved to [bold purple]{path}[/].")
except Exception as e:
logger.warning(f"Failed to save unmanaged records: {e}")
for subdomain, record in new_records.items():
cached_record = self.cached_records.get(subdomain, None)
if cached_record is None:
Expand Down
Loading