Skip to content

Commit 2a58ffd

Browse files
committed
Update github actions workflows
1 parent 9f5a8c4 commit 2a58ffd

6 files changed

Lines changed: 98 additions & 75 deletions

File tree

.github/workflows/docker.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,17 @@ jobs:
1717
IMAGE_NAME: ${{ github.repository_owner }}/alerta-cli
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v2
21-
- name: Variables
22-
id: vars
23-
run: echo "::set-output name=SHORT_COMMIT_ID::$(git rev-parse --short HEAD)"
20+
uses: actions/checkout@v3
2421
- name: Build image
2522
id: docker-build
2623
run: >-
2724
docker build
2825
-t $IMAGE_NAME
2926
-t $REPOSITORY_URL/$IMAGE_NAME:$(cat VERSION)
30-
-t $REPOSITORY_URL/$IMAGE_NAME:${{ steps.vars.outputs.SHORT_COMMIT_ID }}
27+
-t $REPOSITORY_URL/$IMAGE_NAME:$(git rev-parse --short HEAD)
3128
-t $REPOSITORY_URL/$IMAGE_NAME:latest .
3229
- name: Docker Login
33-
uses: docker/login-action@v1
30+
uses: docker/login-action@v2
3431
with:
3532
registry: ${{ env.REPOSITORY_URL }}
3633
username: ${{ github.actor }}
@@ -39,7 +36,7 @@ jobs:
3936
id: docker-push
4037
run: docker push --all-tags $REPOSITORY_URL/$IMAGE_NAME
4138

42-
- uses: act10ns/slack@v1
39+
- uses: act10ns/slack@v2
4340
with:
4441
status: ${{ job.status }}
4542
steps: ${{ toJson(steps) }}

.github/workflows/release.yml

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,80 @@
1-
name: release
1+
name: Release
22

33
on:
44
push:
5-
tags:
6-
- 'v*'
5+
tags: [ 'v*' ]
6+
branches: [ develop ]
77

88
env:
99
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
1010

1111
jobs:
1212
test:
13+
name: Test
1314
runs-on: ubuntu-latest
15+
1416
steps:
15-
- uses: actions/checkout@v2
16-
- name: Install
17-
id: install
18-
run: make install
19-
- name: Lint
20-
id: lint
21-
run: make lint
22-
- name: Test
17+
- uses: actions/checkout@v3
18+
- name: Set up Python 3.11
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: 3.11
22+
- name: Install dependencies
23+
id: install-deps
24+
run: |
25+
python3 -m pip install --upgrade pip
26+
pip install flake8 pytest
27+
pip install -r requirements.txt
28+
pip install -r requirements-dev.txt
29+
pip install .
30+
- name: Pre-commit hooks
31+
id: hooks
32+
run: |
33+
pre-commit run -a --show-diff-on-failure
34+
- name: Test with pytest
2335
id: test
24-
run: make test
25-
26-
- uses: act10ns/slack@v1
36+
env:
37+
DATABASE_URL: postgres://postgres:postgres@localhost:5432/alerta
38+
run: |
39+
pytest --cov=alerta tests/*.py
40+
- uses: act10ns/slack@v2
2741
with:
2842
status: ${{ job.status }}
2943
steps: ${{ toJson(steps) }}
44+
if: failure()
3045

3146
release:
47+
name: Publish
3248
needs: test
3349
runs-on: ubuntu-latest
50+
3451
steps:
35-
- uses: actions/checkout@v2
52+
- uses: actions/checkout@v3
53+
- name: Set up Python 3.11
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: 3.11
3657
- name: Build
3758
id: build
38-
run: make build
59+
run: |
60+
python3 -m pip install --upgrade build
61+
python3 -m build
3962
- name: Publish to PyPI
4063
id: publish
41-
uses: pypa/gh-action-pypi-publish@release/v1
42-
with:
43-
user: __token__
44-
password: ${{ secrets.PYPI_API_TOKEN }}
64+
env:
65+
TWINE_USERNAME: __token__
66+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
67+
run: |
68+
python3 -m pip install --upgrade twine
69+
python3 -m twine check dist/*
70+
python3 -m twine upload --verbose dist/*
4571
46-
- uses: act10ns/slack@v1
72+
- uses: act10ns/slack@v2
4773
with:
4874
status: ${{ job.status }}
4975
steps: ${{ toJson(steps) }}
76+
77+
- name: Test Install
78+
run: |
79+
python3 -m pip install --upgrade alerta-server
80+
python3 -m pip freeze
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
name: CI Tests
1+
name: Tests
22

33
on:
44
push:
5-
branches: [ master, release/* ]
65
pull_request:
76
branches: [ master ]
87

8+
env:
9+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
10+
REPOSITORY_URL: docker.pkg.github.com
11+
912
jobs:
1013
test:
1114
runs-on: ubuntu-latest
12-
env:
13-
REPOSITORY_URL: docker.pkg.github.com
14-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
1515

1616
strategy:
1717
matrix:
18-
python-version: [3.6, 3.7, 3.8, 3.9]
18+
python-version: ['3.8', '3.11']
1919

2020
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v2
23-
- name: Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v2
21+
- uses: actions/checkout@v3
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v4
2524
with:
2625
python-version: ${{ matrix.python-version }}
2726
- name: Install dependencies
@@ -57,8 +56,7 @@ jobs:
5756
docker-compose -f docker-compose.ci.yaml build sut
5857
docker-compose -f docker-compose.ci.yaml up --exit-code-from sut
5958
docker-compose -f docker-compose.ci.yaml rm --stop --force
60-
61-
- uses: act10ns/slack@v1
59+
- uses: act10ns/slack@v2
6260
with:
6361
status: ${{ job.status }}
6462
steps: ${{ toJson(steps) }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
args: ['--django']
2626
- id: requirements-txt-fixer
2727
- id: trailing-whitespace
28-
- repo: https://gitlab.com/pycqa/flake8
28+
- repo: https://github.com/pycqa/flake8
2929
rev: 3.9.2
3030
hooks:
3131
- id: flake8

Makefile

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!make
22

33
VENV=venv
4-
PYTHON=$(VENV)/bin/python
4+
PYTHON=$(VENV)/bin/python3
55
PIP=$(VENV)/bin/pip --disable-pip-version-check
66
FLAKE8=$(VENV)/bin/flake8
77
MYPY=$(VENV)/bin/mypy
88
TOX=$(VENV)/bin/tox
99
PYTEST=$(VENV)/bin/pytest
1010
DOCKER_COMPOSE=docker-compose
1111
PRE_COMMIT=$(VENV)/bin/pre-commit
12+
BUILD=$(VENV)/bin/build
1213
WHEEL=$(VENV)/bin/wheel
1314
TWINE=$(VENV)/bin/twine
1415
GIT=git
@@ -18,46 +19,48 @@ GIT=git
1819
-include .env .env.local .env.*.local
1920

2021
ifndef PROJECT
21-
$(error PROJECT is not set)
22+
$(error PROJECT is not set)
2223
endif
2324

25+
PYPI_REPOSITORY ?= pypi
2426
VERSION=$(shell cut -d "'" -f 2 $(PROJECT)/version.py)
2527

26-
PKG_SDIST=dist/*-$(VERSION).tar.gz
27-
PKG_WHEEL=dist/*-$(VERSION)-*.whl
28-
2928
all: help
3029

31-
$(PIP):
30+
$(VENV):
3231
python3 -m venv $(VENV)
3332

34-
$(FLAKE8): $(PIP)
35-
$(PIP) install flake8==4.0.1
33+
$(FLAKE8): $(VENV)
34+
$(PIP) install flake8
3635

37-
$(MYPY): $(PIP)
38-
$(PIP) install mypy==0.812
36+
$(MYPY): $(VENV)
37+
$(PIP) install mypy
3938

40-
$(TOX): $(PIP)
39+
$(TOX): $(VENV)
4140
$(PIP) install tox
4241

43-
$(PYTEST): $(PIP)
44-
$(PIP) install pytest==6.2.5 pytest-cov==3.0.0
42+
$(PYTEST): $(VENV)
43+
$(PIP) install pytest pytest-cov
44+
45+
$(PRE_COMMIT): $(VENV)
46+
$(PIP) install pre-commit
47+
$(PRE_COMMIT) install
4548

46-
$(PRE_COMMIT): $(PIP)
47-
$(PIP) install pre-commit==2.15.0
49+
$(BUILD): $(VENV)
50+
$(PIP) install --upgrade build
4851

49-
$(WHEEL): $(PIP)
50-
$(PIP) install wheel
52+
$(WHEEL): $(VENV)
53+
$(PIP) install --upgrade wheel
5154

52-
$(TWINE): $(PIP)
53-
$(PIP) install wheel twine
55+
$(TWINE): $(VENV)
56+
$(PIP) install --upgrade wheel twine
5457

5558
ifdef TOXENV
56-
toxparams?=-e $(TOXENV)
59+
toxparams?=-e $(TOXENV)
5760
endif
5861

5962
## install - Install dependencies.
60-
install: $(PIP)
63+
install: $(VENV)
6164
$(PIP) install -r requirements.txt
6265

6366
## hooks - Run pre-commit hooks.
@@ -94,17 +97,13 @@ tag:
9497
$(GIT) push --tags
9598

9699
## build - Build package.
97-
build: $(PIP) $(WHEEL) $(PKG_SDIST) $(PKG_WHEEL)
98-
99-
$(PKG_SDIST):
100-
$(PYTHON) setup.py sdist
101-
102-
$(PKG_WHEEL): $(WHEEL)
103-
$(PYTHON) setup.py bdist_wheel
100+
build: $(BUILD)
101+
$(PYTHON) -m build
104102

105103
## upload - Upload package to PyPI.
106104
upload: $(TWINE)
107-
$(TWINE) upload dist/*
105+
$(TWINE) check dist/*
106+
$(TWINE) upload --repository $(PYPI_REPOSITORY) --verbose dist/*
108107

109108
## clean - Clean source.
110109
clean:

requirements-dev.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
mypy==0.812
2-
pre-commit==2.15.0
3-
pylint==2.11.1
1+
mypy==1.0.1
2+
pre-commit==2.20.0
3+
pylint==2.16.2
44
pytest-cov
55
pytest>=5.4.3
66
python-dotenv
77
requests_mock
8-
twine
9-
wheel

0 commit comments

Comments
 (0)