Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/compare-ds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Compare DS
on:
pull_request_target:
branches: [ master ]
jobs:
build-content:
name: Generate Diff
runs-on: ubuntu-latest
container:
image: fedora:latest
steps:
- name: Install Deps
run: dnf install -y cmake make openscap-utils python3-pyyaml python3-jinja2 git python3-deepdiff python3-requests jq python3-pip
- name: Install deps python
run: pip install gitpython xmldiff
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master
- name: Checkout (CTF)
uses: actions/checkout@v2
with:
repository: mildas/content-test-filtering
path: ctf
- name: Detect content changes in the PR
run: python3 ./ctf/content_test_filtering.py pr --rule --output json ${{ github.event.pull_request.number }} > output.json
- name: Test if there are no content changes
run: echo "::set-output name=CTF_OUTPUT_SIZE::$(stat --printf="%s" output.json)"
id: ctf
- name: Print changes to content detected if any
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: cat output.json
- name: Get product attribute
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
id: product
uses: notiz-dev/github-action-json-property@release
with:
path: 'output.json'
prop_path: 'product'
- name: Build product (master)
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: ./build_product ${{steps.product.outputs.prop}} --datastream-only
- name: Copy built datastream stream to be compared
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: cp build/ssg-${{steps.product.outputs.prop}}-ds.xml ssg-${{steps.product.outputs.prop}}-ds.xml
- name: Checkout
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
uses: actions/checkout@v2
with:
clean: false
- name: Build product
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: ./build_product ${{steps.product.outputs.prop}} --datastream-only
- name: Compare datastreams
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: utils/compare_ds.py ssg-${{steps.product.outputs.prop}}-ds.xml build/ssg-${{steps.product.outputs.prop}}-ds.xml | tee diff.log
env:
PYTHONPATH: ${{ github.workspace }}
- name: Get diff.log
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
id: diff
run: |
body=$(cat diff.log)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=log::$body
- name: Find Comment
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Datastream diff output
- name: Create or update comment
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
This datastream diff is auto generated by the check `Compare DS/Generate Diff`
<details>
<summary>Click here to see the full diff</summary>

```diff
${{ steps.diff.outputs.log }}
```

</details>
edit-mode: replace