Skip to content

Commit

Permalink
Fetch authority information from GitLab
Browse files Browse the repository at this point in the history
  • Loading branch information
atagar committed Oct 11, 2023
2 parents dca09de + 668abcf commit 5e97bd5
Show file tree
Hide file tree
Showing 4 changed files with 1,010 additions and 871 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Testing

on:
push:
branches:
- master
pull_request:

schedule:
- cron: '2 3 * * *'

jobs:
qa:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set Python ${{ matrix.python-version }} environment up
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install development dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Run unit tests
run: |
./run_tests.py --unit
- name: Run integration tests
run: |
sudo apt-get install tor -y
./run_tests.py --unit
15 changes: 12 additions & 3 deletions cache_fallback_directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@

import re
import sys
import json
import datetime
import urllib.request

import stem.directory
import stem.util.system

GITWEB_FALLBACK_LOG = 'https://gitweb.torproject.org/tor.git/log/src/app/config/fallback_dirs.inc'
# call to GitLab API to retrieve file history
GITLAB_FALLBACK_LOG = 'https://gitlab.torproject.org/api/v4/projects/426/repository/files/src%2Fapp%2Fconfig%2Ffallback_dirs.inc/blame?ref=main'
# replace by function getting the right entry out of the JSON
FALLBACK_DIR_LINK = b"href='/tor.git/commit/src/app/config/fallback_dirs.inc\\?id=([^']*)'"

if __name__ == '__main__':
try:
fallback_dir_page = urllib.request.urlopen(GITWEB_FALLBACK_LOG).read()
fallback_dir_commit = re.search(FALLBACK_DIR_LINK, fallback_dir_page).group(1).decode('utf-8')
fallback_dir_commit = sorted(
json.loads(urllib.request.urlopen(GITLAB_FALLBACK_LOG).read()),
key=lambda commit: datetime.datetime.fromisoformat(
commit["commit"]["committed_date"]
),
reverse=True,
)[0]["commit"]["id"]
except:
print("Unable to determine the latest commit to edit tor's fallback directories: %s" % sys.exc_info()[1])
sys.exit(1)
Expand Down
Loading

0 comments on commit 5e97bd5

Please sign in to comment.