Skip to content

Commit c19e835

Browse files
author
Christian Rebischke
authored
Merge pull request #58 from shibumi/shibumi/add-more-github-ci-workflows
add more ci workflows
2 parents 3f20266 + ed2c614 commit c19e835

File tree

2 files changed

+86
-9
lines changed

2 files changed

+86
-9
lines changed

.github/workflows/main.yml

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,56 @@ on: [push, pull_request]
44

55
jobs:
66
vagrant-validation:
7-
87
runs-on: ubuntu-latest
98

109
steps:
1110
- uses: actions/checkout@v1
1211
- name: install packer
13-
run:
14-
./generic-ci.sh install
15-
- name: verify packer configuration
16-
run:
17-
./generic-ci.sh verify
12+
run: ./generic-ci.sh install-packer
13+
14+
- name: verify local.json
15+
run: ./generic-ci.sh verify-local
16+
17+
- name: verify vagrant.json
18+
run: ./generic-ci.sh verify-official
19+
20+
python-syntax-validation:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v1
25+
- name: install flake8
26+
run: ./generic-ci.sh install-flake8
27+
28+
- name: run flake8 checks
29+
run: ./generic-ci.sh flake8
30+
31+
python-format-validation:
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- uses: actions/checkout@v1
36+
- name: install yapf
37+
run: ./generic-ci.sh install-yapf
38+
39+
- name: run yapf checks
40+
run: ./generic-ci.sh yapf
41+
42+
shell-syntax-validation:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v1
47+
- name: run shellcheck
48+
run: ./generic-ci.sh shellcheck
49+
50+
shell-format-validation:
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@v1
55+
- name: install-shfmt
56+
run: ./generic-ci.sh install-shfmt
57+
58+
- name: run shfmt checks
59+
run: ./generic-ci.sh shfmt

generic-ci.sh

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -x
33

44
case $1 in
55

6-
install)
6+
install-packer)
77
PACKER_CURRENT_VERSION="$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')"
88
PACKER_URL="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_linux_amd64.zip"
99
PACKER_SHA256="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_SHA256SUMS"
@@ -20,13 +20,48 @@ case $1 in
2020
grep linux_amd64 "packer_${PACKER_CURRENT_VERSION}_SHA256SUMS" > packer_SHA256SUM_linux_amd64
2121
sha256sum --check --status packer_SHA256SUM_linux_amd64
2222
unzip "packer_${PACKER_CURRENT_VERSION}_linux_amd64.zip"
23+
./packer --version
2324
;;
2425

25-
verify)
26-
./packer --version
26+
install-shfmt)
27+
curl -L https://github.com/mvdan/sh/releases/download/v2.6.4/shfmt_v2.6.4_linux_amd64 -o shfmt
28+
chmod +x ./shfmt
29+
;;
30+
31+
install-yapf)
32+
pip3 install yapf --user
33+
;;
34+
35+
install-flake8)
36+
pip3 install flake8 --user
37+
;;
38+
39+
verify-official)
2740
jq ".\"post-processors\"[0] |= map(select(.\"type\" != \"vagrant-cloud\"))" vagrant.json | ./packer validate -var "iso_url=https://downloads.archlinux.de/iso/$(date +'%Y.%m').01/archlinux-$(date +'%Y.%m').01-x86_64.iso" -var "iso_checksum_url=https://downloads.archlinux.de/iso/$(date +'%Y.%m').01/sha1sums.txt" -
2841
;;
2942

43+
verify-local)
44+
jq ".\"post-processors\"[0] |= map(select(.\"type\" != \"vagrant-cloud\"))" local.json | ./packer validate -var "iso_url=https://downloads.archlinux.de/iso/$(date +'%Y.%m').01/archlinux-$(date +'%Y.%m').01-x86_64.iso" -var "iso_checksum_url=https://downloads.archlinux.de/iso/$(date +'%Y.%m').01/sha1sums.txt" -
45+
;;
46+
47+
# We use + instead of \; here because find doesn't pass
48+
# the exit code through when used with \;
49+
shellcheck)
50+
find . -iname "*.sh" -exec shellcheck {} +
51+
;;
52+
53+
shfmt)
54+
find . -iname "*.sh" -exec ./shfmt -i 2 -ci -d {} +
55+
;;
56+
57+
yapf)
58+
find . -iname "*.py" -exec python3 -m yapf -d {} +
59+
;;
60+
61+
flake8)
62+
find . -iname "*.py" -exec python3 -m flake8 {} +
63+
;;
64+
3065
*)
3166
exit 1
3267
;;

0 commit comments

Comments
 (0)