From 85df9397dea6c753cf61679c4bd7ae0f8e319002 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:31:07 -0600 Subject: [PATCH 1/4] convert to GitHub Actions --- .dockerignore | 5 ----- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ .gitignore | 5 +---- Dockerfile | 7 ------- codeship-services.yml | 4 ---- codeship-steps.yml | 3 --- lambda-example/README.md | 7 +------ lambda-example/codeship-services.yml | 5 ----- lambda-example/codeship-steps.yml | 4 ---- 9 files changed, 26 insertions(+), 38 deletions(-) delete mode 100644 .dockerignore create mode 100644 .github/workflows/ci.yml delete mode 100644 Dockerfile delete mode 100644 codeship-services.yml delete mode 100644 codeship-steps.yml delete mode 100644 lambda-example/codeship-services.yml delete mode 100644 lambda-example/codeship-steps.yml 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..bf980dd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: Test + +on: + push: + branches: + - "**" + tags-ignore: + - "*" + +jobs: + test: + strategy: + matrix: + go-version: [ 1.20 1.21 1.22 ] + + runs-on: ubuntu-latest + 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/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" From c389d45c6c5ce0e971a94b6c1404ccf7b69f832b Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:32:53 -0600 Subject: [PATCH 2/4] dereference matrix.go-version --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf980dd..9b49875 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: test: strategy: matrix: - go-version: [ 1.20 1.21 1.22 ] + go-version: [ '1.20' '1.21' '1.22' ] runs-on: ubuntu-latest steps: @@ -19,6 +19,6 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: matrix.go-version + go-version: ${{ matrix.go-version }} - run: go test -v ./... From 2fdfc6be39f7caa4457606cd9af179ae005aec34 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:34:12 -0600 Subject: [PATCH 3/4] fix yaml syntax --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b49875..c259bc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,11 +9,11 @@ on: jobs: test: + runs-on: ubuntu-latest strategy: matrix: - go-version: [ '1.20' '1.21' '1.22' ] + go-version: [ '1.20', '1.21', '1.22' ] - runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 8416f9d107ea3709540a168b2cbb21b1f50d16ca Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:35:12 -0600 Subject: [PATCH 4/4] go mod tidy --- go.mod | 1 + go.sum | 2 ++ 2 files changed, 3 insertions(+) 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=