-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid finding sizes online for the user
- Loading branch information
1 parent
40312c7
commit 5a51a18
Showing
2 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import json | ||
import requests | ||
|
||
def get_file_size(url): | ||
response = requests.head(url, allow_redirects=True) | ||
if 'Content-Length' not in response.headers: | ||
raise Exception(f"Unable to find size of {url}") | ||
return int(response.headers['Content-Length']) | ||
|
||
|
||
fname="src/main/resources/availableDLVersions.json" | ||
|
||
with open(fname, 'r') as ff: | ||
engines = json.load(ff) | ||
|
||
jar_dict = {} | ||
|
||
for engine in engines["versions"]: | ||
for jar in engine["jars"]: | ||
if jar in jar_dict.keys: | ||
continue | ||
jar_dict[jar] = get_file_size(jar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,36 @@ on: | |
paths: | ||
- src/main/resources/availableDLVersions.json | ||
- .github/workflows/jar_sizes.yml | ||
pull_request: | ||
branches: [ main ] | ||
- .github/get_jar_sizes.py | ||
workflow_dispatch: | ||
jobs: | ||
build-and-run: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Download all engines | ||
run: | | ||
python download-engines.py | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
# Step 2: Set up Python environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' # Specify the Python version | ||
|
||
- name: Get file sizes and generate JSON | ||
run: python .github/get_jar_sizes.py | ||
|
||
- name: Commit and push changes | ||
run: | | ||
# Configure Git | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
# Only commit/push if there are changes | ||
if [ -n "$(git status --porcelain)" ]; then | ||
git add src/main/resources/sizes.json | ||
git commit -m "Update file sizes" | ||
git push | ||
else | ||
echo "No changes to commit." | ||
fi |