File tree Expand file tree Collapse file tree 4 files changed +130
-1
lines changed
Expand file tree Collapse file tree 4 files changed +130
-1
lines changed Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on : [push]
4+
5+ jobs :
6+ create_release :
7+ name : create_release
8+ runs-on : ubuntu-18.04
9+ steps :
10+ - name : Check out code
11+ uses : actions/checkout@v1
12+ - name : create release
13+ id : create_release
14+ uses : actions/create-release@v1
15+ env :
16+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
17+ with :
18+ tag_name : ${{ github.ref }}
19+ release_name : Release ${{ github.ref }}
20+ draft : false
21+ prerelease : false
22+ - name : Output Release URL File
23+ run : echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
24+ - name : Save Release URL File for publish
25+ uses : actions/upload-artifact@v1
26+ with :
27+ name : release_url
28+ path : release_url.txt
29+
30+ build_and_release :
31+ needs : [create_release]
32+ strategy :
33+ matrix :
34+ runtime :
35+ - python3.6
36+ - python3.7
37+ - python3.8
38+ runs-on : ubuntu-18.04
39+ steps :
40+ - uses : actions/checkout@v1
41+ - run : ./make_layer.sh ${{ matrix.runtime }}
42+ - name : Load Release URL File from release job
43+ uses : actions/download-artifact@v1
44+ with :
45+ name : release_url
46+ - name : Get Release File Name & Upload URL
47+ id : get_release_info
48+ run : |
49+ value=`cat release_url/release_url.txt`
50+ echo ::set-output name=upload_url::$value
51+ - name : Upload Release Asset
52+ id : upload-release-asset
53+ uses : actions/upload-release-asset@v1.0.1
54+ env :
55+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
56+ with :
57+ upload_url : ${{ steps.get_release_info.outputs.upload_url }}
58+ asset_path : ./layer_diffoscope_${{ matrix.runtime }}.zip
59+ asset_name : layer_diffoscope_${{ matrix.runtime }}.zip
60+ asset_content_type : application/zip
Original file line number Diff line number Diff line change 11# diffoscope-aws-lambda-layer
2- AWS Lambda layer with diffoscope and everything it needs
2+
3+ A script that prepares an AWS Lambda layer with diffoscope and some tools it needs.
4+
5+ ## How to build
6+
7+ ``` bash
8+ ./make_layer.sh python3.6
9+ ./upload_layer.sh python3.6 # requires properly configured "aws" command
10+ ```
11+
12+ ## How to use in Lambda
13+
14+ ``` python
15+ from diffoscope.logging import line_eraser, setup_logging
16+ from diffoscope.main import create_parser, run_diffoscope
17+ from diffoscope.profiling import ProfileManager, profile
18+ from diffoscope.progress import ProgressManager, Progress
19+
20+
21+ def handler (event , context ):
22+ # ...
23+ args = [files[v1], files[v2], " --html" , output_file]
24+ with profile(" main" , " parse_args" ):
25+ parser, post_parse = create_parser()
26+ parsed_args = parser.parse_args(args)
27+ print (parsed_args)
28+ log_handler = ProgressManager().setup(parsed_args)
29+ with setup_logging(parsed_args.debug, log_handler) as logger:
30+ post_parse(parsed_args)
31+ run_diffoscope(parsed_args)
32+ # serve output_file as text/html
33+ ```
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # TODO
4+ # add zipnote to bin/ (zip package)
5+ # add libarchive-tools
6+
7+ RUNTIME=${1:- python3.6}
8+ PKG_DIR=$( mktemp -d ./d.XXXXXX)
9+ trap ' rm -rf "$PKG_DIR"' EXIT
10+ mkdir $PKG_DIR /bin $PKG_DIR /lib
11+ TARGET=" layer_diffoscope_$RUNTIME .zip"
12+ rm $TARGET
13+
14+ docker run --rm -v $( pwd) :/foo -w /foo lambci/lambda:build-$RUNTIME \
15+ sh -c " \
16+ yum --assumeyes install vim-common && \
17+ cp /usr/bin/xxd ${PKG_DIR} /bin && \
18+ yum --assumeyes install libarchive && \
19+ cp --verbose /usr/lib64/libarchive.so.13 ${PKG_DIR} /lib/libarchive.so && \
20+ cp --verbose /usr/lib64/liblzo2.so.2 ${PKG_DIR} /lib/ && \
21+ chown --verbose $( id --user) :$( id --group) ${PKG_DIR} /lib/* \
22+ "
23+ docker run --user $( id --user) :$( id --group) --rm -v $( pwd) :/foo -w /foo lambci/lambda:build-$RUNTIME \
24+ sh -c " \
25+ pip install diffoscope jsbeautifier jsondiff -t ${PKG_DIR} /python --no-cache-dir && \
26+ cp --verbose ${PKG_DIR} /python/bin/* ${PKG_DIR} /bin/ \
27+ "
28+
29+ cd $PKG_DIR
30+ zip -r --move ../$TARGET *
31+ cd ..
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ RUNTIME=${1:- python3.6}
4+ TARGET=" layer_diffoscope_$RUNTIME .zip"
5+
6+ DESCRIPTION=$( unzip -p $TARGET ' */diffoscope*/METADATA' | grep ' ^Version' )
7+ aws lambda publish-layer-version --layer-name diffoscope --description " $DESCRIPTION " --zip-file fileb://$TARGET --compatible-runtimes $RUNTIME
You can’t perform that action at this time.
0 commit comments