Skip to content

Commit

Permalink
CI: set kosli-trail as env-var (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Jan 16, 2024
1 parent bd14e75 commit f1b38aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/trails.yml
Expand Up @@ -11,6 +11,7 @@ env:
KOSLI_ORG: cyber-dojo-trails
KOSLI_FLOW: ${{ vars.KOSLI_FLOW }} # dashboard
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN_TRAILS }}
KOSLI_TRAIL: ${GITHUB_SHA}


jobs:
Expand All @@ -28,6 +29,7 @@ jobs:
echo "image_name=cyberdojo/${{ env.KOSLI_FLOW }}:${TAG}" >> ${GITHUB_OUTPUT}
echo "image_tag=${TAG}" >> ${GITHUB_OUTPUT}
create-kosli-trail:
runs-on: ubuntu-latest
steps:
Expand All @@ -46,7 +48,8 @@ jobs:

- name: Begin Kosli Trail
run:
kosli begin trail "${GITHUB_SHA}"
kosli begin trail "${{ env.KOSLI_TRAIL }}"


lint:
needs: [variables, create-kosli-trail]
Expand All @@ -66,23 +69,23 @@ jobs:

- name: Run Rubocop linter on source, report results to Kosli Trail
run: |
export LINT_EVIDENCE_DIR=/tmp/evidence/lint
mkdir -p "${LINT_EVIDENCE_DIR}"
export KOSLI_EVIDENCE_PATHS=/tmp/evidence/lint
mkdir -p "${KOSLI_EVIDENCE_PATHS}"
gem install rubocop
set +e
rubocop --raise-cop-error . > "${LINT_EVIDENCE_DIR}"/rubocop.log
rubocop --raise-cop-error . > "${KOSLI_EVIDENCE_PATHS}"/rubocop.log
STATUS=$?
set -e
KOSLI_LINT_COMPLIANT=$([ ${STATUS} = 0 ] && echo true || echo false)
cp .rubocop.yml "${LINT_EVIDENCE_DIR}"
KOSLI_COMPLIANT=$([ ${STATUS} = 0 ] && echo true || echo false)
cp .rubocop.yml "${KOSLI_EVIDENCE_PATHS}"
kosli attest generic \
--compliant="${KOSLI_LINT_COMPLIANT}" \
--evidence-paths="${LINT_EVIDENCE_DIR}" \
--name=lint \
--trail="${GITHUB_SHA}"
--compliant="${KOSLI_COMPLIANT}" \
--evidence-paths="${KOSLI_EVIDENCE_PATHS}" \
--name=lint
exit $STATUS
pull-request:
needs: [variables, create-kosli-trail]
runs-on: ubuntu-latest
Expand All @@ -105,6 +108,7 @@ jobs:
--name=pull-request
--trail="${GITHUB_SHA}"


build-image:
needs: [variables, create-kosli-trail]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/trails_staging.yml
Expand Up @@ -74,10 +74,10 @@ jobs:
STATUS=$?
set -e
KOSLI_LINT_COMPLIANT=$([ ${STATUS} = 0 ] && echo true || echo false)
KOSLI_COMPLIANT=$([ ${STATUS} = 0 ] && echo true || echo false)
cp .rubocop.yml "${LINT_EVIDENCE_DIR}"
kosli attest generic \
--compliant="${KOSLI_LINT_COMPLIANT}" \
--compliant="${KOSLI_COMPLIANT}" \
--evidence-paths="${LINT_EVIDENCE_DIR}" \
--name=lint \
--trail="${GITHUB_SHA}"
Expand Down

0 comments on commit f1b38aa

Please sign in to comment.