Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 134 additions & 2 deletions .depot/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,143 @@ on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
push:
branches: [main]

name: "depot: PR"

concurrency:
group: depot-pr-${{ github.head_ref || github.ref }}
cancel-in-progress: true
Comment thread
cursor[bot] marked this conversation as resolved.

jobs:
noop:

lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- name: Check go mod tidy
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum || {
echo "::error::Please run 'go mod tidy' and commit changes"
exit 1
}
- name: Check go fmt
run: |
if gofmt -d -s . | grep -q .; then
echo "::error::Please run 'gofmt -w .' and commit changes"
exit 1
fi
- name: Build binary (needed for lint tests)
run: make build
- name: Run lint tests
env:
REPLICATED_API_TOKEN: ${{ secrets.REPLICATED_API_TOKEN }}
run: make test-lint

unit-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- run: make test-unit

pact-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- name: Install pact
run: |
curl -L -o /tmp/pact.tar.gz https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v2.0.0/pact-2.0.0-linux-x86_64.tar.gz
echo "94ea52ef7d6c9dacf431dde7138717d96714131a /tmp/pact.tar.gz" | shasum -c -
mkdir -p /tmp/pact-standalone
tar -C /tmp/pact-standalone --strip-components=1 -xzf /tmp/pact.tar.gz
echo "/tmp/pact-standalone/bin" >> "$GITHUB_PATH"
rm /tmp/pact.tar.gz
- name: Setup pact environment
if: github.ref == 'refs/heads/main'
run: |
echo "PACT_VERSION=${{ github.sha }}" >> "$GITHUB_ENV"
echo "PACT_BROKER_BASE_URL=${{ secrets.PACT_BROKER_BASE_URL }}" >> "$GITHUB_ENV"
echo "PACT_BROKER_TOKEN=${{ secrets.PACT_BROKER_TOKEN }}" >> "$GITHUB_ENV"
- run: make test-pact
- if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
run: make publish-pact
- if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
run: |
make can-i-deploy || echo "::warning:: can-i-deploy says no; provider(s) must successfully verify before release"

integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- run: make build
- run: make test-integration

build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- run: make build

security:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Run semgrep
run: |
docker run --rm -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config=p/golang /src

gate:
if: always()
needs: [lint, unit-tests, pact-tests, integration-tests, build, security]
runs-on: ubuntu-latest
steps:
- run: echo "Depot PR workflow registered"
- name: Check all results
run: |
results=(
"${{ needs.lint.result }}"
"${{ needs.unit-tests.result }}"
"${{ needs.pact-tests.result }}"
"${{ needs.integration-tests.result }}"
"${{ needs.build.result }}"
"${{ needs.security.result }}"
)
for r in "${results[@]}"; do
if [[ "$r" == "failure" || "$r" == "cancelled" ]]; then
echo "::error::Job failed: $r"
exit 1
fi
done
echo "All checks passed"
104 changes: 104 additions & 0 deletions .depot/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
on:
push:
tags:
- 'v*'

name: "depot: Release"

jobs:

build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- run: make test-unit
- name: Install pact
run: |
curl -L -o /tmp/pact.tar.gz https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v2.0.0/pact-2.0.0-linux-x86_64.tar.gz
echo "94ea52ef7d6c9dacf431dde7138717d96714131a /tmp/pact.tar.gz" | shasum -c -
mkdir -p /tmp/pact-standalone
tar -C /tmp/pact-standalone --strip-components=1 -xzf /tmp/pact.tar.gz
echo "/tmp/pact-standalone/bin" >> "$GITHUB_PATH"
rm /tmp/pact.tar.gz
- run: make test-pact
- run: make build
Comment thread
cursor[bot] marked this conversation as resolved.

release:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- name: Install goreleaser
run: go install github.com/goreleaser/goreleaser/v2@v2.14.3
- name: Run goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goreleaser release --clean

docker-publish:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- name: Build binary with version
run: |
VERSION=${GITHUB_REF_NAME#v}
LDFLAGS="-ldflags \"-X github.com/replicatedhq/replicated/pkg/version.version=${VERSION}\""
make build LDFLAGS="${LDFLAGS}"
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.
- name: Build Docker image
run: |
VERSION=${GITHUB_REF_NAME#v}
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f1,2)
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "MAJOR=${MAJOR}" >> "$GITHUB_ENV"
echo "MINOR=${MINOR}" >> "$GITHUB_ENV"
docker build -f Dockerfile.release -t replicated/vendor-cli:${VERSION} .
docker tag replicated/vendor-cli:${VERSION} replicated/vendor-cli:latest
docker tag replicated/vendor-cli:${VERSION} replicated/vendor-cli:${MAJOR}
docker tag replicated/vendor-cli:${VERSION} replicated/vendor-cli:${MINOR}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push images
run: |
docker push replicated/vendor-cli:${VERSION}
docker push replicated/vendor-cli:latest
docker push replicated/vendor-cli:${MAJOR}
docker push replicated/vendor-cli:${MINOR}
Comment thread
cursor[bot] marked this conversation as resolved.

docs:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- name: Build binary
run: make build
- name: Generate and publish docs
env:
GITHUB_TOKEN: ${{ secrets.DOCS_REPO_TOKEN }}
run: ./scripts/generate-docs.sh
109 changes: 0 additions & 109 deletions .github/workflows/main.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest

RUN apk add --no-cache ca-certificates curl git nodejs npm \
&& update-ca-certificates \
&& npm install -g replicated-lint

ENV IN_CONTAINER=1

LABEL com.replicated.vendor_cli="true"

WORKDIR /out

COPY bin/replicated /replicated

ENTRYPOINT ["/replicated"]
Loading