diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 6ed59eb..0000000 --- a/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -codeship-services.yml -codeship-steps.yml -config.example.json -lambda-example/ -README.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c259bc1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: Test + +on: + push: + branches: + - "**" + tags-ignore: + - "*" + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [ '1.20', '1.21', '1.22' ] + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + + - run: go test -v ./... diff --git a/.gitignore b/.gitignore index 1dba6e9..13bdad3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,16 @@ # Serverless directories .serverless -package-lock.json # golang output binary directory bin # local creds and stuff -.env -aws.env +*.env *.aes config*.json # dev tools metadata .idea/ -node_modules/ .vscode lambda-example/go.mod diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 31fd050..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM golang:1.19 - -WORKDIR /app - -COPY . ./ - -RUN go get diff --git a/codeship-services.yml b/codeship-services.yml deleted file mode 100644 index cc87773..0000000 --- a/codeship-services.yml +++ /dev/null @@ -1,4 +0,0 @@ -app: - build: - image: silinternational/personnel-sync - dockerfile: Dockerfile diff --git a/codeship-steps.yml b/codeship-steps.yml deleted file mode 100644 index ee81868..0000000 --- a/codeship-steps.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: test - service: app - command: bash -c "go test ./..." diff --git a/go.mod b/go.mod index bae4695..49466d5 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ replace github.com/silinternational/personnel-sync/v6 => ./ require ( github.com/Jeffail/gabs/v2 v2.7.0 + github.com/aws/aws-lambda-go v1.46.0 github.com/aws/aws-sdk-go v1.49.17 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.20.0 diff --git a/go.sum b/go.sum index 33471bd..2fecd70 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2Aawl github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Jeffail/gabs/v2 v2.7.0 h1:Y2edYaTcE8ZpRsR2AtmPu5xQdFDIthFG0jYhu5PY8kg= github.com/Jeffail/gabs/v2 v2.7.0/go.mod h1:dp5ocw1FvBBQYssgHsG7I1WYsiLRtkUaB1FEtSwvNUw= +github.com/aws/aws-lambda-go v1.46.0 h1:UWVnvh2h2gecOlFhHQfIPQcD8pL/f7pVCutmFl+oXU8= +github.com/aws/aws-lambda-go v1.46.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= github.com/aws/aws-sdk-go v1.49.17 h1:Cc+7LgPjKeJkF2SdNo1IkpQ5Dfl9HCZEVw9OP3CPuEI= github.com/aws/aws-sdk-go v1.49.17/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= diff --git a/lambda-example/README.md b/lambda-example/README.md index a68073d..d57bf04 100644 --- a/lambda-example/README.md +++ b/lambda-example/README.md @@ -11,8 +11,7 @@ public repository. ## Setup The contents of this `lambda-example` directory are intended to downloaded/copied to your own filesystem and -repository. In this directory are a couple files for use with [Codeship](https://codeship.com). If you don't use -Codeship you can remove them and replace them with whatever is appropriate for your CI/CD provider. +repository. After downloading the files, copy `config.example.json` to `config.json` and edit as needed. Also copy `.env.example` to `.env` and insert AWS credentials for Serverless to use to deploy the Lambda function. @@ -23,7 +22,3 @@ the easiest way to do all this is using the included `Dockerfile` and `docker-co Run `make deploy`. This will build the Docker image, run `go get` inside the container, build the Go binary, and use Serverless to deploy the Lambda function to the default Serverless stage `dev`, but you can update the command in the Makefile to change the stage as desired. - -If you want to automate deployment with Codeship, encrypt the `.env` file to `.env.encrypted` and connect your private -project repo with Codeship. By default it is configured to only deploy _production_ when changes are pushed to the -main branch. diff --git a/lambda-example/codeship-services.yml b/lambda-example/codeship-services.yml deleted file mode 100644 index 000f446..0000000 --- a/lambda-example/codeship-services.yml +++ /dev/null @@ -1,5 +0,0 @@ -app: - build: - dockerfile_path: Dockerfile - encrypted_env_file: .env.encrypted - cached: true diff --git a/lambda-example/codeship-steps.yml b/lambda-example/codeship-steps.yml deleted file mode 100644 index 86c74ef..0000000 --- a/lambda-example/codeship-steps.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: deploy_prod - service: app - tag: main - command: bash -c "./build.sh && serverless deploy --verbose"