Skip to content

Commit

Permalink
πŸ› fix: fix error when ~/.config/dns-manager does not exist (#3)
Browse files Browse the repository at this point in the history
* πŸ› fix: fix error when `~/.config/dns-manager` does not exist

* πŸ› fix: fix action
  • Loading branch information
zrr1999 authored Nov 4, 2024
1 parent 60f5a5d commit 955fea8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
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

0 comments on commit 955fea8

Please sign in to comment.