-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (89 loc) · 2.47 KB
/
jq.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
92
93
94
---
#
# .github/workflows/jq.yml
#
name: jq Workflow
on: # yamllint disable-line rule:truthy
pull_request:
defaults:
run:
shell: bash
jobs:
stage1:
name: Change Check
runs-on: 'ubuntu-latest'
outputs:
docs_changed: ${{ steps.check_file_changed.outputs.docs_changed }}
steps:
- name: Checkout Repo
id: checkout-repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
submodules: recursive
- name: Get Change List
id: check_file_changed
run: |
# Diff HEAD with the previous commit then output to stdout.
printf "=== Which files changed? ===\n"
GIT_DIFF="$(git diff --name-only HEAD^ HEAD)"
printf "%s\n" "${GIT_DIFF}"
printf "\n"
# Check if the files are present in the changed file list (added, modified, deleted) then output to stdout.
HAS_DIFF=false
printf "=== Which jq files changed? ===\n"
if printf "%s\n" "${GIT_DIFF}" | grep -E '^(jq/.*[.]jq|.github/workflows/jq.yml)$'; then
HAS_DIFF=true
fi
printf "\n"
# Did Golang files change?
printf "=== Did Golang files change? ===\n"
printf "%s\n" "${HAS_DIFF}"
printf "\n"
# Set the output named "docs_changed"
printf "%s=%s\n" "docs_changed" "${HAS_DIFF}" >> "${GITHUB_OUTPUT}"
stage2:
name: jq Checks
strategy:
matrix:
os: ["ubuntu-latest"]
runs-on: "${{ matrix.os }}"
needs: [stage1]
if: needs.stage1.outputs.docs_changed == 'True'
steps:
- name: Checkout Repo
id: checkout-repo
uses: actions/checkout@v3
- name: Set up jq
id: setup-jq
run: |
sudo apt install -y jq
- name: Show jq version
id: jq-version
run: |
jq --version
- name: Checkout bats-core
id: checkout-bats-core
uses: actions/checkout@v3
with:
repository: bats-core/bats-core
path: bats-core
- name: Install Bats
id: install-bats-core
run: |
cd bats-core
sudo ./install.sh /usr/local
- name: CD to jq Dir
id: cd-to-jq-dir
run: |
pwd
ls
cd ./jq
pwd
ls
- name: Testing with Bats tests
id: jq-bats-run
run: |-
cd ./jq
./for_each ../../.github/citools/jq/jq-bats