Skip to content

Commit

Permalink
Merge pull request #9 from coreweave/dhix/change-ci
Browse files Browse the repository at this point in the history
feat(ceph_exporter): Add CI to build images on PRs, branches, pushes, and tags, as well as release.
  • Loading branch information
ADustyOldMuffin authored Mar 28, 2024
2 parents 439055e + 9e4f472 commit 8a402bf
Show file tree
Hide file tree
Showing 39 changed files with 187 additions and 153 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2024 DigitalOcean
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This should build and push images to the Github Registry on branches, PRs, and tags.
name: Build image

on:
push:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{raw}}
type=ref,event=pr
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
56 changes: 0 additions & 56 deletions .github/workflows/build_and_push.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DigitalOcean
# Copyright 2024 DigitalOcean
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/run_tests.yml → .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DigitalOcean
# Copyright 2024 DigitalOcean
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,26 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Tests
name: Create releases

on:
push:
branches: [main]
pull_request:
branches: ['**']
branches:
- "main"

jobs:
create-releases:
runs-on: ubuntu-latest

run-go-tests:
runs-on: ubuntu-20.04

permissions:
issues: write
pull-requests: write
contents: write

steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.20'

# We only test the Ceph package since main depends on go-ceph
- name: Go test
run: go test -v ./ceph
- name: Checkout
uses: actions/checkout@v4
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/run_build.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2024 DigitalOcean
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

branches:
- main
preset: "angular"
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
- "@semantic-release/github"
repositoryUrl: "[email protected]/coreweave/ceph_exporter.git"
analyzeCommits:
- path: "@semantic-release/commit-analyzer"
releaseRules:
- type: "feature"
release: "minor"
- type: "update"
release: "minor"
- type: "refactor"
release: "patch"
- type: "bugfix"
release: "patch"
- type: "docs"
release: "patch"
parserOpts:
noteKeywords:
- "BREAKING CHANGE"
- "BREAKING CHANGES"
- "BREAKING"
- "BREAKS"
publish:
- path: "@semantic-release/github"
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DigitalOcean
# Copyright 2024 DigitalOcean
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,10 +37,8 @@ RUN \
ADD . $APPLOC
WORKDIR $APPLOC
RUN go get -d
# The `-tags nautilus` instructs go-ceph to enable additional support nautilus release.
# See https://github.com/ceph/go-ceph#installation
RUN if [ -n "${TEST}" ]; then go test -tags nautilus -v -race -count=1 ./...; fi
RUN go build -tags nautilus -o /bin/ceph_exporter
RUN if [ -n "${TEST}" ]; then go test -v -race -count=1 ./...; fi
RUN go build -o /bin/ceph_exporter

FROM ubuntu:20.04

Expand Down
3 changes: 2 additions & 1 deletion ceph/cluster_usage.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@ package ceph

import (
"encoding/json"

"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
)
Expand Down
2 changes: 1 addition & 1 deletion ceph/cluster_usage_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion ceph/conn.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 2 additions & 1 deletion ceph/crashes.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@ package ceph
import (
"encoding/json"
"fmt"

"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
)
Expand Down
2 changes: 1 addition & 1 deletion ceph/crashes_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion ceph/exporter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion ceph/health.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion ceph/health_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
14 changes: 14 additions & 0 deletions ceph/mds.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ceph

import (
Expand Down
14 changes: 14 additions & 0 deletions ceph/mds_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ceph

import (
Expand Down
2 changes: 1 addition & 1 deletion ceph/mocks_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion ceph/monitors.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 DigitalOcean
// Copyright 2024 DigitalOcean
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 8a402bf

Please sign in to comment.