Skip to content

Commit

Permalink
fix: Updated dependencies and added nightly release (#161)
Browse files Browse the repository at this point in the history
* chore: bump github.com/aws/aws-sdk-go-v2 from 1.32.3 to 1.32.5

Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.32.3 to 1.32.5.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@v1.32.3...v1.32.5)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: bump github.com/aws/aws-sdk-go-v2/credentials

Bumps [github.com/aws/aws-sdk-go-v2/credentials](https://github.com/aws/aws-sdk-go-v2) from 1.17.39 to 1.17.46.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@credentials/v1.17.39...credentials/v1.17.46)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/credentials
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: bump github.com/aws/aws-sdk-go-v2/service/lambda

Bumps [github.com/aws/aws-sdk-go-v2/service/lambda](https://github.com/aws/aws-sdk-go-v2) from 1.63.0 to 1.69.0.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@service/s3/v1.63.0...service/s3/v1.69.0)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/service/lambda
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: bump golang.org/x/crypto from 0.28.0 to 0.31.0 (#160)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.28.0 to 0.31.0.
- [Commits](golang/crypto@v0.28.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump github.com/aws/aws-sdk-go-v2/config from 1.27.41 to 1.28.5 (#159)

Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.27.41 to 1.28.5.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@config/v1.27.41...config/v1.28.5)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/config
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ci: add nightly publishing logic

* tests: added test for httpClient

* tests: remove env check

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
karl-cardenas-coding and dependabot[bot] authored Dec 28, 2024
1 parent b2d6295 commit 2d86482
Show file tree
Hide file tree
Showing 8 changed files with 272 additions and 123 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/image-prune.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Container Image Cleanup

on:
workflow_run:
workflows: ["Nightly Release"]
types: [completed]
workflow_dispatch:



jobs:
prune:
name: Prune Container Images
runs-on: ubuntu-latest
steps:

- uses: snok/container-retention-policy@v2
with:
image-names: go-lambda-cleanup
cut-off: 1 day ago UTC
timestamp-to-use: created_at
account-type: personal
org-name: karl-cardenas-coding
keep-at-least: 1
skip-tags: nightly
dry-run: false
token-type: github-token
token: ${{ secrets.GITHUB_TOKEN }}


- name: Actions Ntfy
run: |
curl \
-u ${{ secrets.NTFY_TOKEN }} \
-H "go-lambda-cleanup Nightly Release" \
-H "X-Tags: warning" \
-H "Markdown: yes" \
-d 'The Nightly Release job failed for go-lambda-cleanup. Check out the GitHub Actions logs for more details.' \
${{ secrets.NTFY_URL }}
63 changes: 63 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Nightly Release

on:
schedule:
# Run every day at 11:00 UTC
- cron: '0 11 * * *'
workflow_dispatch:


env:
GO_VERSION: '1.23'

jobs:
build-and-release:
runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
id: go

- name: Generate AWS region file
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws ec2 describe-regions --all-regions --region us-east-1 --query "Regions[].RegionName" --output text >> cmd/aws-regions.txt
- name: Update Dependencies
run: go get -u ./...

- name: Execute Go tests
run: make tests

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3


- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
build-args: VERSION="nightly"
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:nightly
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) karl-cardenas-coding
# SPDX-License-Identifier: MIT

FROM golang:1.23.2-alpine3.20 AS builder
FROM golang:1.23.4-alpine3.21 AS builder

LABEL org.opencontainers.image.source="http://github.com/karl-cardenas-coding/go-lambda-cleanup"
LABEL org.opencontainers.image.description="A solution for removing previous versions of AWS Lambdas"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build: ## Build the binary file

tests: ## Run tests
@echo "Running tests"
go test -race ./...
go test -shuffle on -race ./...


tests-coverage: ## Start Go Test with code coverage
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![codecov](https://codecov.io/gh/karl-cardenas-coding/go-lambda-cleanup/graph/badge.svg?token=S8SY4ZA2ZA)](https://codecov.io/gh/karl-cardenas-coding/go-lambda-cleanup)
[![Go Report Card](https://goreportcard.com/badge/github.com/karl-cardenas-coding/go-lambda-cleanup/v2)](https://goreportcard.com/report/github.com/karl-cardenas-coding/go-lambda-cleanup/v2)
[![Nighly Build](https://github.com/karl-cardenas-coding/go-lambda-clean-up/actions/workflows/nightly.yaml/badge.svg)](https://github.com/karl-cardenas-coding/go-lambda-cleanup/actions/workflows/nightly.yaml)


<p align="center">
Expand Down Expand Up @@ -57,6 +58,16 @@ time=05/23/22 level=info msg="124 MB of storage space will be removed in an actu
time=05/23/22 level=info msg="Job Duration Time: 1.454406s"
```

### Nightly Release

A nightly release is available as a Docker image. The nightly release is a snapshot of the main branch and automatically updated with the latest minor depedencies updates.

```shell
docker pull ghcr.io/karl-cardenas-coding/go-lambda-cleanup:nightly
```



## Usage

```shell
Expand Down
28 changes: 28 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package cmd

import (
"context"
"crypto/tls"
"fmt"
"net/http"
"os"
"testing"

Expand Down Expand Up @@ -371,3 +373,29 @@ func TestNoLambdas(t *testing.T) {

})
}

func TestCreateHTTPClient(t *testing.T) {

client := createHTTPClient()

// Check if the client is not nil
if client == nil {
t.Fatalf("Expected non-nil HTTP client")
}

// Check if the transport is of type *http.Transport
transport, ok := client.Transport.(*http.Transport)
if !ok {
t.Fatalf("Expected transport to be of type *http.Transport, got %T", client.Transport)
}

// Check if the minimum TLS version is set to TLS 1.2
if transport.TLSClientConfig.MinVersion != tls.VersionTLS12 {
t.Errorf("Expected MinVersion to be TLS 1.2, got %v", transport.TLSClientConfig.MinVersion)
}

// Check if ForceAttemptHTTP2 is set to true
if !transport.ForceAttemptHTTP2 {
t.Errorf("Expected ForceAttemptHTTP2 to be true, got %v", transport.ForceAttemptHTTP2)
}
}
74 changes: 39 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,43 @@ module github.com/karl-cardenas-coding/go-lambda-cleanup/v2
go 1.23

require (
github.com/aws/aws-sdk-go-v2 v1.32.3
github.com/aws/aws-sdk-go-v2/config v1.27.41
github.com/aws/aws-sdk-go-v2/credentials v1.17.39
github.com/aws/aws-sdk-go-v2/service/lambda v1.63.0
github.com/aws/aws-sdk-go-v2 v1.32.7
github.com/aws/aws-sdk-go-v2/config v1.28.7
github.com/aws/aws-sdk-go-v2/credentials v1.17.48
github.com/aws/aws-sdk-go-v2/service/lambda v1.69.2
github.com/docker/go-connections v0.5.0
github.com/dustin/go-humanize v1.0.1
github.com/hashicorp/go-version v1.7.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.1
github.com/testcontainers/testcontainers-go v0.33.0
github.com/testcontainers/testcontainers-go/modules/localstack v0.33.0
github.com/testcontainers/testcontainers-go v0.34.0
github.com/testcontainers/testcontainers-go/modules/localstack v0.34.0
gopkg.in/yaml.v3 v3.0.1
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.19 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.19 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.32.0 // indirect
github.com/aws/smithy-go v1.22.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 // indirect
github.com/aws/smithy-go v1.22.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.3.1+incompatible // indirect
github.com/docker/docker v27.4.1+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand All @@ -48,9 +49,9 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.17.10 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
Expand All @@ -61,27 +62,30 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
go.opentelemetry.io/otel v1.33.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 // indirect
go.opentelemetry.io/otel/metric v1.33.0 // indirect
go.opentelemetry.io/otel/sdk v1.33.0 // indirect
go.opentelemetry.io/otel/trace v1.33.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
google.golang.org/grpc v1.69.2 // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 2d86482

Please sign in to comment.