Skip to content

Commit

Permalink
Add integration test for file provenance type
Browse files Browse the repository at this point in the history
  • Loading branch information
Brend-Smits authored and AnnieJovitha committed Oct 7, 2021
1 parent 8c78a6b commit 71df7f7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/bin/diff-filter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

FIRST_ARTIFACT=$1
SECOND_ARTIFACT=$2
# Comma seperated line of text of attributes to skip, examples are: buildFinishedOn,sha1
# SKIP_LINES=$3

diff_artifacts() {
diff -f $FIRST_ARTIFACT $SECOND_ARTIFACT > difference.txt
grep -vF "buildFinishedOn" difference.txt > difference2.txt
grep -vF "sha1" difference2.txt > difference3.txt
cat difference3.txt
# cat difference.txt | grep -vF "buildFinishedOn" | grep -vF "sha1" | grep -vF "buildInvocationId" | grep -vE "^c" | grep -vE "^."
}

diff_artifacts
45 changes: 45 additions & 0 deletions .github/workflows/integration-test-file-type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Integration test file provenance

on:
push:
branches:
- tests
workflow_dispatch:

jobs:
build:
name: Build artifact
runs-on: ubuntu-latest
steps:
# traditionally you would build your code here and generate an artifact
- name: Create first artifact
run: echo "onion, tomato, jalapeno, cilantro, lime, salt" > salsa.txt

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: '*.txt'

generate-provenance:
needs: build
name: Generate build provenance
runs-on: ubuntu-latest
steps:
# checkout only required to run local action (defined in this repo)
- name: Checkout
uses: actions/checkout@v2

- name: Download build artifact
uses: actions/download-artifact@v2

- name: Generate provenance
# use action in the root directory
uses: ./
with:
artifact_path: artifact/

- name: Get example build.provenance
run: curl https://gist.githubusercontent.com/Brend-Smits/f4cc4f6ccb140712796c23b75dbf70e0/raw/5040c0a727f9e2e6e337ac987fff36b5ff67757f/gistfile1.txt >> example-build.provance

- name: Check and Match contents of provenance
run: sh ../bin/diff-checker.sh artifact/build.provance example-build.provance

0 comments on commit 71df7f7

Please sign in to comment.