Skip to content

Commit 5eff6af

Browse files
committed
Add tests to GH workflow
1 parent 096dde3 commit 5eff6af

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ jobs:
88
runs-on: ubuntu-18.04
99
steps:
1010
- name: Check out code
11+
if: startsWith(github.ref, 'v')
1112
uses: actions/checkout@v1
1213
- name: create release
14+
if: startsWith(github.ref, 'v')
1315
id: create_release
1416
uses: actions/create-release@v1
1517
env:
@@ -20,8 +22,10 @@ jobs:
2022
draft: false
2123
prerelease: false
2224
- name: Output Release URL File
25+
if: startsWith(github.ref, 'v')
2326
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
2427
- name: Save Release URL File for publish
28+
if: startsWith(github.ref, 'v')
2529
uses: actions/upload-artifact@v1
2630
with:
2731
name: release_url
@@ -30,6 +34,7 @@ jobs:
3034
build_and_release:
3135
needs: [create_release]
3236
strategy:
37+
fail-fast: false
3338
matrix:
3439
runtime:
3540
- python3.6
@@ -39,16 +44,30 @@ jobs:
3944
steps:
4045
- uses: actions/checkout@v1
4146
- run: ./make_layer.sh ${{ matrix.runtime }}
47+
48+
- run: |
49+
mkdir opt
50+
cd opt
51+
unzip ../layer_diffoscope_${{ matrix.runtime }}.zip
52+
cd ..
53+
ls -l
54+
docker run -e DOCKER_LAMBDA_DEBUG=1 --rm -v "$PWD":/var/task:ro,delegated -v "$PWD"/opt/:/opt:ro,delegated lambci/lambda:${{ matrix.runtime }} tests.run 2> /tmp/test_results
55+
cat /tmp/test_results
56+
grep '^OK$' /tmp/test_results
57+
4258
- name: Load Release URL File from release job
59+
if: startsWith(github.ref, 'v')
4360
uses: actions/download-artifact@v1
4461
with:
4562
name: release_url
4663
- name: Get Release File Name & Upload URL
64+
if: startsWith(github.ref, 'v')
4765
id: get_release_info
4866
run: |
4967
value=`cat release_url/release_url.txt`
5068
echo ::set-output name=upload_url::$value
5169
- name: Upload Release Asset
70+
if: startsWith(github.ref, 'v')
5271
id: upload-release-asset
5372
uses: actions/upload-release-asset@v1.0.1
5473
env:

diffoscoping.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from diffoscope.logging import line_eraser, setup_logging
2+
from diffoscope.main import create_parser, run_diffoscope
3+
from diffoscope.profiling import ProfileManager, profile
4+
from diffoscope.progress import ProgressManager, Progress
5+
6+
7+
def calculate(args):
8+
with profile("main", "parse_args"):
9+
parser, post_parse = create_parser()
10+
parsed_args = parser.parse_args(args)
11+
print(parsed_args)
12+
log_handler = ProgressManager().setup(parsed_args)
13+
with setup_logging(parsed_args.debug, log_handler) as logger:
14+
post_parse(parsed_args)
15+
return run_diffoscope(parsed_args)

test/extension_2020_1_13_0.crx

1.08 MB
Binary file not shown.

test/extension_2020_1_7_1.crx

1.07 MB
Binary file not shown.

tests.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import unittest
2+
3+
from diffoscoping import calculate
4+
5+
6+
def run(event, context):
7+
unittest.TextTestRunner().run(
8+
unittest.TestLoader().loadTestsFromTestCase(ChromeExtensionTestCase)
9+
)
10+
11+
12+
class ChromeExtensionTestCase(unittest.TestCase):
13+
@classmethod
14+
def setUpClass(cls):
15+
report_file = "/tmp/out.html"
16+
calculate(
17+
[
18+
"test/extension_2020_1_7_1.crx",
19+
"test/extension_2020_1_13_0.crx",
20+
"--text",
21+
report_file,
22+
]
23+
)
24+
with open(report_file) as f:
25+
cls.report = f.read()
26+
27+
def test_no_fallbacks(self):
28+
self.assertNotIn("Falling back", self.__class__.report)
29+
30+
def test_jsonlike_manifest(self):
31+
self.assertIn("2020.1.7.1", self.__class__.report)
32+
33+
def test_no_tools_missing(self):
34+
self.assertNotIn("missing", self.__class__.report)

0 commit comments

Comments
 (0)