-
Notifications
You must be signed in to change notification settings - Fork 26
108 lines (97 loc) · 3.59 KB
/
Copy pathdocker.yml
File metadata and controls
108 lines (97 loc) · 3.59 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Build Docker images
on:
push:
tags:
- '*'
branches:
- '*'
jobs:
build-docker:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout sources
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Create version tag
shell: bash
run: echo "tag=ghcr.io/openleadr/openleadr-rs:$(git show -s --format="%ct-%h" $GITHUB_SHA)" >> $GITHUB_ENV
- name: "'main' tag on main branch"
if: github.ref == 'refs/heads/main'
run: echo "tag=${{ env.tag }},ghcr.io/openleadr/openleadr-rs:main" >> $GITHUB_ENV
- name: "explicit release tags & 'latest' tag"
if: github.ref_type == 'tag'
run: |
REF_NAME=${{ github.ref_name }}
TAGS="${{ env.tag }},ghcr.io/openleadr/openleadr-rs:${REF_NAME}"
if [[ $REF_NAME =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Stable release detected. Adding 'latest' tag."
TAGS="${TAGS},ghcr.io/openleadr/openleadr-rs:latest"
else
echo "Pre-release or non-standard tag detected. Skipping 'latest'."
fi
echo "tag=${TAGS}" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Build Docker image
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
file: ./vtn.Dockerfile
tags: "${{ env.tag }}"
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
elaad-tests:
name: Run ElaadNL Tests
needs: build-docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Get docker build information
uses: actions/download-artifact@v8
id: download_docker_images
with:
pattern: '*.dockerbuild'
- name: Extract docker image SHA
run: |
gunzip ${{ steps.download_docker_images.outputs.download-path }}/*.dockerbuild --suffix .dockerbuild
tar -xf OpenLEADR~openleadr-rs*
echo sha=$(cat index.json | jq .manifests[0].digest -r) >> $GITHUB_ENV
- name: Checkout ElaadNL openadr3-client
uses: actions/checkout@v7
with:
repository: 'ElaadNL/openadr3-client'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
run: uv python install
- id: install_dependencies
name: Install dependencies
run: uv sync --locked --all-extras --dev
- id: run_tests
name: Run tests
run: uv run pytest tests/oadr310/vtn --ignore=tests/oadr310/vtn/mqtt --openleadr-310-version=${{ env.sha }}
continue-on-error: true
- name: Print test outcome
run: |
if [ "${{ steps.run_tests.outcome }}" == "failure" ]; then
echo "## :heavy_exclamation_mark: ElaadNL tests failed :x:" >> $GITHUB_STEP_SUMMARY
echo "This might be due to incompatible changes in either the EladdNL test suite or OpenLEADR" >> $GITHUB_STEP_SUMMARY
else
echo "## Tests passed :white_check_mark:" >> $GITHUB_STEP_SUMMARY
fi