Skip to content

Commit b5e8ce6

Browse files
authored
Merge pull request #1382 from projectsyn/ci/reduce-gh-token-permissions
Reduce permissions for GitHub actions tokens
2 parents 3e4312b + 7fe6810 commit b5e8ce6

5 files changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/build-virtualenv-caches.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
schedule:
1010
- cron: '0 4 * * MON'
1111

12+
permissions: {}
13+
1214
jobs:
1315
build-lint-virtualenvs:
1416
runs-on: ubuntu-latest

.github/workflows/cleanup-pr-tag.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ name: Delete closed PR container image tag
66
types:
77
- closed
88

9+
permissions:
10+
packages: write
11+
912
jobs:
1013
cleanup-pr-tag:
1114
runs-on: ubuntu-latest

.github/workflows/publish-pypi.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
branches:
1111
- master
1212

13+
permissions: {}
14+
1315
jobs:
1416
build-and-publish:
1517
# Skip job on forks

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
branches:
55
- master
66

7+
permissions: {}
8+
79
jobs:
810
lints:
911
runs-on: ubuntu-latest

tests/test_tools.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import stat
66
import sys
77

8-
from datetime import datetime, timedelta
8+
from datetime import datetime
99
from pathlib import Path
1010
from typing import Optional
1111
from unittest.mock import patch, MagicMock
@@ -276,6 +276,7 @@ def test_install_jb(config: Config, fs, capsys):
276276
config.managed_tools = {}
277277
_setup_tool_github_responses()
278278
assert not tools.MANAGED_TOOLS_PATH.exists()
279+
before_install = datetime.now().replace(microsecond=0)
279280

280281
tools.install_tool(config, "jb", None)
281282

@@ -299,7 +300,10 @@ def test_install_jb(config: Config, fs, capsys):
299300
assert len(state) == 1
300301
assert "jb" in state
301302
updated = datetime.fromisoformat(state["jb"])
302-
assert datetime.now() - updated < timedelta(seconds=1)
303+
# NOTE(sg): we're not checking timedelta here, instead we're verifying that the updated
304+
# timestamp is between now and before we installed the tool.
305+
assert datetime.now() > updated
306+
assert updated >= before_install
303307

304308

305309
@pytest.mark.skipif(

0 commit comments

Comments
 (0)