From 71df7f782f3123603a43e5264156d864f3456c4d Mon Sep 17 00:00:00 2001 From: Brend Smits Date: Mon, 4 Oct 2021 15:17:11 +0200 Subject: [PATCH] Add integration test for file provenance type --- .github/bin/diff-filter.sh | 16 +++++++ .../workflows/integration-test-file-type.yml | 45 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/bin/diff-filter.sh create mode 100644 .github/workflows/integration-test-file-type.yml diff --git a/.github/bin/diff-filter.sh b/.github/bin/diff-filter.sh new file mode 100644 index 00000000..3b8b1888 --- /dev/null +++ b/.github/bin/diff-filter.sh @@ -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 \ No newline at end of file diff --git a/.github/workflows/integration-test-file-type.yml b/.github/workflows/integration-test-file-type.yml new file mode 100644 index 00000000..bb8c6f42 --- /dev/null +++ b/.github/workflows/integration-test-file-type.yml @@ -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