Skip to content

Commit

Permalink
Merge pull request #23 from nyaruka/actions
Browse files Browse the repository at this point in the history
Convert to github actions
  • Loading branch information
rowanseymour authored Nov 22, 2019
2 parents 67c8b38 + 68e521b commit 4783699
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 52 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .github/actions/elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM docker:stable

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
21 changes: 21 additions & 0 deletions .github/actions/elasticsearch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Nyaruka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 19 additions & 0 deletions .github/actions/elasticsearch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Elasticsearch GitHub Action

This [GitHub Action](https://github.com/features/actions) sets up a Elasticsearch server.

# Usage

See [action.yml](action.yml)

Basic:
```yaml
steps:
- uses: nyaruka/elasticsearch@v1
with:
elastic version: '6.8.5' # See https://hub.docker.com/_/elasticsearch for available versions
```
# License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
14 changes: 14 additions & 0 deletions .github/actions/elasticsearch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Setup Elasticsearch'
author: 'Nyaruka'
branding:
icon: 'database'
color: 'blue'
inputs:
# See https://hub.docker.com/_/elasticsearch for supported versions
elastic version:
description: 'Version of Elasticsearch to use'
required: false
default: '7.4.2'
runs:
using: 'docker'
image: 'Dockerfile'
6 changes: 6 additions & 0 deletions .github/actions/elasticsearch/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

docker_run="docker run -d -p 9200:9200 -p 9300:9300 -e 'discovery.type=single-node' elasticsearch:$INPUT_ELASTIC_VERSION"

echo "RUNNING: $docker_run"
sh -c "$docker_run"
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI
on: [push, pull_request]
jobs:
test:
name: Test
strategy:
matrix:
pg-version: ['10', '11']
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Install ElasticSearch
uses: ./.github/actions/elasticsearch
with:
elastic version: '6.8.5'

- name: Install PostgreSQL
uses: harmon758/postgresql-action@v1
with:
postgresql version: ${{ matrix.pg-version }}
postgresql db: elastic_test
postgresql user: temba
postgresql password: temba

- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x

- name: Run tests
run: go test -p=1 -coverprofile=coverage.text -covermode=atomic ./...

- name: Upload coverage
if: success()
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}

release:
name: Release
needs: [test]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x

- name: Publish release
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ require (
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
)

go 1.13
2 changes: 1 addition & 1 deletion indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func setup(t *testing.T) (*sql.DB, *elastic.Client) {
testDB, err := ioutil.ReadFile("testdb.sql")
assert.NoError(t, err)

db, err := sql.Open("postgres", "postgres://localhost/elastic_test?sslmode=disable")
db, err := sql.Open("postgres", "postgres://temba:temba@localhost:5432/elastic_test?sslmode=disable")
assert.NoError(t, err)

_, err = db.Exec(string(testDB))
Expand Down

0 comments on commit 4783699

Please sign in to comment.