-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for update release assets script
- Loading branch information
1 parent
4348f8e
commit 552a7b6
Showing
4 changed files
with
68 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
semantic-version==2.10.0 | ||
PyGithub==1.59.1 | ||
PyYAML==6.0.1 | ||
GitPython==3.1.36 | ||
GitPython==3.1.36 | ||
pytest==7.4.3 |
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,17 @@ | ||
version: 0.1.0 | ||
|
||
layout: | ||
hello-world.txt: | ||
- shell: | | ||
echo "hello world!" > hello-world.txt | ||
hello-world.zip: | ||
- shell: | | ||
echo "hello!" > hello.txt | ||
echo "world!" > world.txt | ||
# reset the creation and modification times to a fixed value | ||
touch -a -m -t 197001010000.00 hello.txt world.txt | ||
checksums.txt: | ||
- shell: | | ||
shasum -a 256 ${{ layout.root }}/* > checksums.txt | ||
# Remove the layout root from the checksums.txt | ||
sed -i '' -e "s|${{ layout.root }}/||g" checksums.txt |
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,30 @@ | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
import yaml | ||
from update_release_assets import ReleaseLayout | ||
|
||
SCRIPT_PATH = Path(__file__) | ||
TEST_DIR = SCRIPT_PATH.parent / 'test-data' | ||
|
||
def test_release_layout(): | ||
spec = TEST_DIR / 'release-layout.yml' | ||
release_layout = ReleaseLayout(spec) | ||
with TemporaryDirectory() as tmp_dir: | ||
tmp_path = Path(tmp_dir) | ||
release_layout.make(tmp_path, []) | ||
|
||
for artifact in yaml.safe_load(spec.read_text())['layout'].keys(): | ||
artifact_path = tmp_path / artifact | ||
assert artifact_path.is_file() | ||
|
||
if artifact == "hello-world.txt": | ||
content = artifact_path.read_text() | ||
assert content == "hello world!\n" | ||
if artifact == "checksums.txt": | ||
content = artifact_path.read_text() | ||
# The hash of the hello-world.txt is deterministic, so we can assert it here. | ||
assert "ecf701f727d9e2d77c4aa49ac6fbbcc997278aca010bddeeb961c10cf54d435a hello-world.txt" in content | ||
# The has of the hello-world.zip is not deterministic, so we can't assert its hash. | ||
assert "hello-world.zip" in content | ||
|
||
|