Skip to content

Commit

Permalink
Merge pull request #21 from tinkerbell/lint-and-format-checks-in-ci
Browse files Browse the repository at this point in the history
Lint and format checks in ci
  • Loading branch information
gianarb authored Nov 10, 2020
2 parents 24f9c82 + f133299 commit 09adeb8
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 11 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
which nix &>/dev/null && use nix
33 changes: 33 additions & 0 deletions .github/workflows/ci-non-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash ../../shell.nix
# shellcheck shell=bash

set -eux

failed=0

if ! git ls-files '*.md' '*.yaml' '*.yml' | xargs prettier --list-different --write; then
failed=1
fi

if ! git ls-files '*.json' | xargs -I '{}' sh -c 'jq --sort-keys . {} > {}.t && mv {}.t {}'; then
failed=1
fi

if ! shfmt -f . | xargs shfmt -s -l -d; then
failed=1
fi

if ! shfmt -f . | xargs shellcheck; then
failed=1
fi

if ! terraform fmt -write -recursive deploy/terraform/; then
failed=1
fi

if ! git diff | (! grep .); then
failed=1
fi

exit "$failed"
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: For each commit and PR
on:
push:
pull_request:

jobs:
validation:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
lfs: true
- name: Install nix
uses: cachix/install-nix-action@v12
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Run ci-checks.sh
run: ./.github/workflows/ci-non-go.sh
12 changes: 6 additions & 6 deletions .github/workflows/vagrant-packet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'ci-check/vagrant-setup')
runs-on: vagrant
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Vagrant Test
run: |
export VAGRANT_DEFAULT_PROVIDER="virtualbox"
go test --timeout 1h -v ./test/_vagrant
- name: Checkout
uses: actions/checkout@v2
- name: Vagrant Test
run: |
export VAGRANT_DEFAULT_PROVIDER="virtualbox"
go test --timeout 1h -v ./test/_vagrant
11 changes: 9 additions & 2 deletions deploy/tls/ca-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
"profiles": {
"server": {
"expiry": "8760h",
"usages": ["signing", "key encipherment", "server auth"]
"usages": [
"signing",
"key encipherment",
"server auth"
]
},
"signing": {
"expiry": "8760h",
"usages": ["signing", "key encipherment"]
"usages": [
"signing",
"key encipherment"
]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/vagrant/scripts/tinkerbell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ main() (
fi

if [ ! -f ./.env ]; then
./generate-envrc.sh eth1 > .env
./generate-envrc.sh eth1 >.env
fi

# shellcheck disable=SC1091
Expand Down
4 changes: 2 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ start_registry() (
bootstrap_docker_registry() (
docker_login

# osie looks for tink-worker:latest, so we have to play with it a bit
# https://github.com/tinkerbell/osie/blob/master/apps/workflow-helper.sh#L66
# osie looks for tink-worker:latest, so we have to play with it a bit
# https://github.com/tinkerbell/osie/blob/master/apps/workflow-helper.sh#L66
docker_mirror_image "${TINKERBELL_TINK_WORKER_IMAGE}" "${TINKERBELL_HOST_IP}/tink-worker:latest"
)

Expand Down
14 changes: 14 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let _pkgs = import <nixpkgs> { };
in { pkgs ? import (_pkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
#branch@date: nixpkgs-unstable@2020-11-04
rev = "dfea4e4951a3cee4d1807d8d4590189cf16f366b";
sha256 = "02j7f5l2p08144b2fb7pg6sbni5km5y72k3nk3i7irddx8j2s04i";
}) { } }:

with pkgs;

mkShell {
buildInputs = [ go nodePackages.prettier shellcheck shfmt terraform ];
}

0 comments on commit 09adeb8

Please sign in to comment.