forked from open-telemetry/build-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (83 loc) · 2.72 KB
/
semconvgen.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Semantic Convention Generator
on:
push:
tags: [ '**' ]
branches:
- main
- 'feature/**'
pull_request:
branches:
- main
- 'feature/**'
paths:
- .github/workflows/semconvgen.yml
- 'semantic-conventions/**'
jobs:
tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: semantic-conventions/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: install dev-dependencies
run: |
pip install -U pip
pip install -U setuptools wheel
pip install -r dev-requirements.txt
- name: Check formatting (black)
run: black --check --diff .
- name: Fast basic linting (flake8)
run: flake8 .
- name: install
run: pip install -U -e .
- name: Check imports (isort)
run: isort --check --diff .
- name: run tests
run: pytest -v
- name: Slow linting (pylint)
run: pylint *.py src/
- name: Type checking (mypy)
run: mypy src/
- name: Build the Docker image
run: pip wheel --no-deps . && docker build . -t semconvgen && docker run --rm semconvgen --help
build-and-publish-docker:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Build the wheel
run: |
pip install -U pip setuptools wheel
pip wheel --no-deps ./semantic-conventions/ --wheel-dir semantic-conventions/
- name: Build the Docker image
run: docker build semantic-conventions/. -t semconvgen
- name: Push the Docker image
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
function tag_and_push {
docker tag semconvgen "otel/semconvgen:${1}" && docker push "otel/semconvgen:${1}"
}
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
tag_and_push "latest"
elif [[ "${GITHUB_REF}" =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
TAG="${GITHUB_REF#"refs/tags/v"}"
tag_and_push "${TAG}"
else
tag_and_push "${GITHUB_REF#"refs/tags/"}"
fi
- name: Push the Dev Docker image
if: startsWith(github.ref, 'refs/heads/feature/')
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
function tag_and_push {
docker tag semconvgen "otel/semconvgen:${1}" && docker push "otel/semconvgen:${1}"
}
TAG="${GITHUB_REF#"refs/heads/"}"
TAG="${TAG/"/"/"-"}"
tag_and_push "${TAG}"