Skip to content

Commit 8752db4

Browse files
committed
Configure Github Actions
1 parent b18f838 commit 8752db4

File tree

9 files changed

+99
-7
lines changed

9 files changed

+99
-7
lines changed

.github/workflows/publish-build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish Build
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
# support traditional versions, and dev versions
8+
tags: ["*.*.*","*.*.*-*"]
9+
10+
jobs:
11+
12+
publish:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Build the Docker image
19+
run: |
20+
export DOCKER_IMAGE=mtconnect-python:$(date +%s)
21+
echo "DOCKER_IMAGE=${DOCKER_IMAGE}" >> $GITHUB_ENV
22+
docker build . --file Dockerfile --tag ${DOCKER_IMAGE}
23+
- name: Bump Version
24+
run: |
25+
./scripts/run_container.sh ${DOCKER_IMAGE} scripts/set_version.sh "${GITHUB_REF}"
26+
echo "VERSION_CHANGE=$(git diff --exit-code)" >> $GITHUB_ENV
27+
- name: Commit Change
28+
if: ${{ vars.VERSION_CHANGE == '1' }}
29+
run: |
30+
git add .
31+
git commit -m 'Bump Version'
32+
git tag -d ${GITHUB_REF}
33+
git tag ${GITHUB_REF}
34+
git push --force origin ${GITHUB_REF}

.github/workflows/validate-build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Validate Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
11+
validate:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Build the Docker image
18+
run: |
19+
export DOCKER_IMAGE=mtconnect-python:$(date +%s)
20+
echo "DOCKER_IMAGE=${DOCKER_IMAGE}" >> $GITHUB_ENV
21+
docker build . --file Dockerfile --tag ${DOCKER_IMAGE}
22+
- name: Test Format
23+
run: ./scripts/run_container.sh ${DOCKER_IMAGE} scripts/format_package.sh --check
24+
- name: Test Package
25+
run: ./scripts/run_container.sh ${DOCKER_IMAGE} scripts/test_package.sh

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ FROM python:3.8-slim as base
22

33
WORKDIR /data
44

5-
# Install poetry
6-
RUN pip3 install poetry
5+
# Install deps
6+
RUN pip3 install poetry && \
7+
apt update && \
8+
apt install git -y
79

810
# Copy depdencies and install base packages
911
COPY pyproject.toml poetry.lock ./

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,29 @@ build:
66
develop: build
77
./scripts/run_develop_container.sh ${IMAGE_NAME} bash
88

9+
run: build
10+
./scripts/run_container.sh ${IMAGE_NAME} bash
11+
912
test: build
1013
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/test_package.sh
1114

15+
test.format: build
16+
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/format_package.sh --check
17+
18+
1219
format: build
1320
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/format_package.sh
1421

22+
1523
lint: build
16-
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/lint_package.sh
24+
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/lint_package.sh
1725

1826
PYPI_USER?=${PYPI_USER}
1927
PYPI_PASSWORD?=${PYPI_PASSWORD}
2028
publish: build
21-
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/publish_package.sh
29+
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/publish_package.sh
30+
31+
# This is only here for completeness. This should only be called via CI
32+
VERSION?=${VERSION}
33+
version: build
34+
./scripts/run_develop_container.sh ${IMAGE_NAME} scripts/set_version.sh ${VERSION}

scripts/format_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
python3 -m black .
3+
python3 -m black . "$@"

scripts/lint_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
python3 -m pylint mtconnect tests
3+
python3 -m pylint mtconnect tests "$@"

scripts/run_container.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -lt 2 ]; then
4+
echo "Please supply image name and command to run"
5+
exit 1
6+
fi
7+
8+
image_name=$1
9+
10+
docker run --name run-ctr --rm ${image_name} "${@:2}"

scripts/set_version.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -ne 1 ]; then
4+
echo "Please supply version"
5+
exit 1
6+
fi
7+
8+
poetry version "$@"

scripts/test_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
python3 -m unittest
3+
python3 -m unittest "$@"

0 commit comments

Comments
 (0)