diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml deleted file mode 100644 index 9cd6169..0000000 --- a/.buildkite/pipeline.yaml +++ /dev/null @@ -1,16 +0,0 @@ -steps: -- command: - - "make ci_test" - label: ":llama: Tests" - agents: - - "queue=default" -- command: - - "make ci_build" - label: ":golang: Build" - agents: - - "queue=default" -- command: - - "make ci_lint" - label: ":llama: Linting" - agents: - - "queue=default" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0dd0975 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + pull_request: + push: + branches: [master] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - run: make ci_test + + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - run: make ci_build + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - run: make ci_lint diff --git a/.github/workflows/mirror-ci-image.yml b/.github/workflows/mirror-ci-image.yml new file mode 100644 index 0000000..327022b --- /dev/null +++ b/.github/workflows/mirror-ci-image.yml @@ -0,0 +1,46 @@ +name: Mirror CI image + +# Anonymous pulls from public ECR hit a rate limit on GitHub runners. +# This copies the gridx dev image to GHCR, where CI pulls it from. +# Runs on every change to this file and on manual dispatch. +on: + push: + paths: + - .github/workflows/mirror-ci-image.yml + workflow_dispatch: + inputs: + source_tag: + description: Tag of public.ecr.aws/gridx/base-images to mirror + default: modbus-dev-1.21.latest + target_tag: + description: Tag to publish under ghcr.io/grid-x/modbus-dev + default: go1.21 + +jobs: + mirror: + runs-on: ubuntu-latest + permissions: + packages: write + env: + SOURCE: public.ecr.aws/gridx/base-images:${{ inputs.source_tag || 'modbus-dev-1.21.latest' }} + TARGET: ghcr.io/grid-x/modbus-dev:${{ inputs.target_tag || 'go1.21' }} + steps: + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull source image + run: | + for attempt in 1 2 3 4 5 6; do + docker pull "$SOURCE" && exit 0 + echo "pull failed, retry $attempt in 30s" + sleep 30 + done + exit 1 + + - name: Push to GHCR + run: | + docker tag "$SOURCE" "$TARGET" + docker push "$TARGET" diff --git a/Makefile b/Makefile index 09f4279..0df2007 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,9 @@ GO_FILES := $(shell find . -type f -name "*.go") GO_BUILD := CGO_ENABLED=0 go build -ldflags "-w -s" -GO_TOOLS := public.ecr.aws/gridx/base-images:modbus-dev-1.21.latest +GO_TOOLS := ghcr.io/grid-x/modbus-dev:go1.21 DOCKER_RUN := docker run --init --rm -v $$PWD:/go/src/github.com/grid-x/modbus -w /go/src/github.com/grid-x/modbus GO_RUN := ${DOCKER_RUN} ${GO_TOOLS} bash -c -BRANCH := $(shell echo ${BUILDKITE_BRANCH} | sed 's/\//_/g') - all: bin/ .PHONY: test