Skip to content

Commit

Permalink
Use Github Actions for CI (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek-sumo committed Nov 26, 2020
1 parent 94641cc commit 8f4ebb9
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 12 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
markdownlint:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: install markdownlint
run: gem install mdl
# - name: markdownlint check
# run: make markdownlint

shellcheck:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: install shellcheck
run: |
curl --retry 10 --retry-max-time 120 --retry-delay 5 -Lo- https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz | tar -xJf -
sudo cp shellcheck-v0.7.1/shellcheck /usr/local/bin && rm -rf shellcheck-v0.7.1
- name: shellcheck
run: make shellcheck

test:
runs-on: ubuntu-20.04
needs: [markdownlint, shellcheck]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- run: gem install bundler
- name: yq
run: |
curl --retry 10 --retry-max-time 120 --retry-delay 5 -L -o /tmp/yq https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64
chmod +x /tmp/yq
sudo mv /tmp/yq /usr/local/bin/yq
- name: test
run: make test

build:
runs-on: ubuntu-20.04
needs: [markdownlint, shellcheck, test]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- run: gem install bundler
- name: yq
run: |
curl --retry 10 --retry-max-time 120 --retry-delay 5 -L -o /tmp/yq https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64
chmod +x /tmp/yq
sudo mv /tmp/yq /usr/local/bin/yq
- name: build
run: make build
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
shellcheck:
./ci/shellcheck.sh

test:
./ci/tests.sh

build:
./ci/build.sh
5 changes: 2 additions & 3 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# shellcheck disable=SC2154
VERSION="${TRAVIS_TAG:-0.0.0}"
Expand Down Expand Up @@ -72,8 +72,7 @@ function set_up_github() {
local token="${1}"
local branch="${2}"

git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis CI"
git config --global user.name "Continuous Integration"
git remote add origin-repo "https://${token}@github.com/SumoLogic/sumologic-kubernetes-collection.git" > /dev/null 2>&1
git fetch --unshallow origin-repo

Expand Down
11 changes: 11 additions & 0 deletions ci/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e

echo "Checking the bash scripts with shellcheck..."
find . ! -path '*deploy/helm/sumologic/conf/setup/setup.sh' ! -path "*/tmp/*" -name '*.sh' -type 'f' -print |
while read -r file; do
# Run tests in their own context
echo "Checking ${file} with shellcheck"
shellcheck --enable all "${file}"
done
11 changes: 2 additions & 9 deletions ci/tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

VERSION="${TRAVIS_TAG:-0.0.0}"
Expand Down Expand Up @@ -53,14 +54,6 @@ function test_fluentd_plugins() {
done
}

echo "Checking the bash scripts with shellcheck..."
find . ! -path '*deploy/helm/sumologic/conf/setup/setup.sh' ! -path "*/tmp/*" -name '*.sh' -type 'f' -print |
while read -r file; do
# Run tests in their own context
echo "Checking ${file} with shellcheck"
shellcheck --enable all "${file}"
done

# Test if template files are generated correctly for various values.yaml
echo "Test helm templates generation"
./tests/run.sh || (echo "Failed testing templates" && exit 1)
Expand Down
9 changes: 9 additions & 0 deletions vagrant/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,12 @@ test-receiver-mock-logs:

test-receiver-mock-metrics:
kubectl exec $(shell kubectl get pod -l app=receiver-mock -o jsonpath="{.items[0].metadata.name}" -n receiver-mock) -it -n receiver-mock -- curl http://localhost:3000/metrics

shellcheck:
$(MAKE) -C ${root_dir} shellcheck

test:
$(MAKE) -C ${root_dir} test

build:
$(MAKE) -C ${root_dir} build

0 comments on commit 8f4ebb9

Please sign in to comment.