diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f2f54493 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +--- +name: CI +on: # yamllint disable-line rule:truthy + pull_request: + workflow_call: +jobs: + test_frontend: + name: Test alertmanager frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: make clean + - run: make all + working-directory: ./ui/app + - run: make assets + - run: make apiv2 + - run: git diff --exit-code + + test: + name: Test + runs-on: ubuntu-latest + # Whenever the Go version is updated here, .promu.yml + # should also be updated. + container: + image: quay.io/prometheus/golang-builder:1.19-base + steps: + - uses: actions/checkout@v3 + - uses: prometheus/promci@v0.0.2 + - uses: ./.github/promci/actions/setup_environment + - run: make diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..e85360a0 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,27 @@ +name: golangci-lint +on: + pull_request: + paths: + - "go.sum" + - "go.mod" + - "**.go" + - "scripts/errcheck_excludes.txt" + - ".github/workflows/golangci-lint.yml" + - ".golangci.yml" + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: install Go + uses: actions/setup-go@v2 + with: + go-version: 1.19.x + - run: make build + - name: Lint + uses: golangci/golangci-lint-action@v3.4.0 + with: + version: v1.51.2 diff --git a/.github/workflows/mixin.yml b/.github/workflows/mixin.yml new file mode 100644 index 00000000..e3c0c980 --- /dev/null +++ b/.github/workflows/mixin.yml @@ -0,0 +1,22 @@ +name: mixin +on: + pull_request: + paths: + - "doc/alertmanager-mixin/**" + +jobs: + mixin: + name: mixin-lint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: install Go + uses: actions/setup-go@v2 + with: + go-version: 1.19.x + # pin the mixtool version until https://github.com/monitoring-mixins/mixtool/issues/135 is merged. + - run: go install github.com/monitoring-mixins/mixtool/cmd/mixtool@2282201396b69055bb0f92f187049027a16d2130 + - run: go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest + - run: go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest + - run: make -C doc/alertmanager-mixin lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..3f818579 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +--- +name: Publish +on: # yamllint disable-line rule:truthy + push: + branches: + - main +jobs: + ci: + name: Run ci + uses: ./.github/workflows/ci.yml + + publish_main: + name: Publish main branch artefacts + runs-on: ubuntu-latest + needs: ci + steps: + - uses: actions/checkout@v3 + - uses: prometheus/promci@v0.0.2 + - uses: ./.github/promci/actions/publish_main + with: + docker_hub_login: ${{ secrets.docker_hub_login }} + docker_hub_password: ${{ secrets.docker_hub_password }} + quay_io_login: ${{ secrets.quay_io_login }} + quay_io_password: ${{ secrets.quay_io_password }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9538aa83 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +--- +name: Release +on: # yamllint disable-line rule:truthy + push: + tags: + - v* +jobs: + ci: + name: Run ci + uses: ./.github/workflows/ci.yml + + publish_release: + name: Publish release arfefacts + runs-on: ubuntu-latest + needs: ci + steps: + - uses: actions/checkout@v3 + - uses: prometheus/promci@v0.0.2 + - uses: ./.github/promci/actions/publish_release + with: + docker_hub_login: ${{ secrets.docker_hub_login }} + docker_hub_password: ${{ secrets.docker_hub_password }} + quay_io_login: ${{ secrets.quay_io_login }} + quay_io_password: ${{ secrets.quay_io_password }} + github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index aa4b7800..7ef77d32 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ !/.travis.yml !/.promu.yml !/api/v2/openapi.yaml +!.github/workflows/*.yml diff --git a/Makefile b/Makefile index c6bfcad0..e9da94c7 100644 --- a/Makefile +++ b/Makefile @@ -78,3 +78,11 @@ clean: template/email.tmpl \ api/v2/models api/v2/restapi api/v2/client - @cd $(FRONTEND_DIR) && $(MAKE) clean + +# In github actions we skip the email test for now. Service containers in github +# actions currently have a bug, see https://github.com/prometheus/alertmanager/pull/3299 +# So define a test target, that skips the email test for now. +.PHONY: test +test: $(GOTEST_DIR) + @echo ">> running all tests, except notify/email" + $(GOTEST) $(test-flags) $(GOOPTS) `go list ./... | grep -v notify/email`