-
Notifications
You must be signed in to change notification settings - Fork 3
91 lines (80 loc) · 3.05 KB
/
test-action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: "Smoke tests"
on:
workflow_dispatch:
push:
paths:
- .github/workflows/test-action.yml
permissions:
contents: write
actions: write
jobs:
generate_info:
name: "Generate dependency information"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: "Generate dependency information"
shell: bash
env:
APPLICATION: go-mkopensource
APPLICATION_TYPE: internal
BUILD_HOME: '.'
BUILD_TMP: '${{ runner.temp }}/license'
SCRIPTS_HOME: '.'
GIT_TOKEN: ${{ github.token }}
NODE_IMAGE: 'node:14.13.1-alpine'
run: |
# Commit dummy license files
: > DEPENDENCY_LICENSES.md
: > DEPENDENCIES.md
git add DEPENDENCY_LICENSES.md DEPENDENCIES.md
# Generate license information
export GO_IMAGE=$(grep -e 'FROM golang:' "build-aux/docker/go_builder.dockerfile" | cut -d ' ' -f2 )
#Copy test data to another folder since it can't be used from there
cp -a ./test-data ./ui
export NPM_PACKAGES=$( echo -e "./ui/package.json\n./ui/package-lock.json" )
mkdir -p "${BUILD_TMP}"
build-aux/generate.sh --unparsable-packages ./unparsable-packages.yaml
- name: "Verify if changes were made by dependabot"
id: changed-by-dependabot
uses: datawire/go-mkopensource/actions/[email protected]
with:
branches_to_skip: master
push_changes: false
- name: "Check that action didn't do any changes"
run: |
if [[ "${{ steps.changed-by-dependabot.outputs.is_dirty }}" == 'true' ]]; then
echo "::error:: Action indicates that the repo was dirty"
exit 1
fi
- name: "Save dependency changes made by the last committer"
id: changed-by-dependabot2
uses: datawire/go-mkopensource/actions/[email protected]
with:
branches_to_skip: master
actor: ${{ github.actor }}
push_changes: false
- name: "Check that action committed changes to the repository"
if: github.ref_type == 'branch'
run: |
if [[ "${{ steps.changed-by-dependabot2.outputs.license_information_committed }}" != 'true' ]]; then
echo "::error:: Action indicates that the repo was not dirty"
exit 1
fi
DESTINATION_BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
DIFF=$(git diff --stat --cached origin/${DESTINATION_BRANCH})
if [[ -z "${DIFF}" ]]; then
echo "::error:: There weren't any files committed."
exit 1
fi
if ! grep -e '^\s*DEPENDENCY_LICENSES.md' <(echo "${DIFF}") > /dev/null; then
echo "::error:: File DEPENDENCY_LICENSES.md was not modified, but it should have been."
exit 1
fi