-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (121 loc) · 4.11 KB
/
Copy pathmain.yml
File metadata and controls
133 lines (121 loc) · 4.11 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Test
on:
pull_request:
branches: [master]
push:
branches: [master]
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
DEBIAN_FRONTEND: noninteractive
PYTHONDONTWRITEBYTECODE: 1
PYTHONUNBUFFERED: 1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Switch to current branch
run: git checkout ${{ env.BRANCH }}
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Restore pre-commit cache
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
pre-commit-${{ runner.os }}
- uses: pre-commit/action@v3.0.1
pytest:
strategy:
matrix:
odoo_version: ["6.0", "6.1", "7.0", "8.0", "9.0", "10.0", "11.0", "12.0", "13.0", "14.0", "15.0", "16.0", "17.0", "18.0", "19.0"]
fail-fast: false
runs-on: ubuntu-latest
needs: pre-commit
env:
DEBIAN_FRONTEND: noninteractive
PYTHONDONTWRITEBYTECODE: 1
PYTHONUNBUFFERED: 1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Switch to current branch
run: git checkout ${{ env.BRANCH }}
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Restore uv cache
uses: actions/cache@v5
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --locked --all-extras --dev
- name: Run pytest
run: uv run pytest --odoo-version ${{ matrix.odoo_version }} --no-cache -v
- name: Minimize uv cache
run: uv cache prune --ci
build-and-push:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: pytest
permissions:
contents: read
packages: write
attestations: write
id-token: write
strategy:
matrix:
version: ["6.0", "6.1", "7.0", "8.0", "9.0", "10.0", "11.0", "12.0", "13.0", "14.0", "15.0", "16.0", "17.0", "18.0", "19.0"]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.version }}
type=raw,value=latest,enable=${{ matrix.version == env.LATEST_VERSION }}
labels: |
org.opencontainers.image.title=Odoo ${{ matrix.version }}
org.opencontainers.image.description=Odoo Community ${{ matrix.version }} - isOdoo Image
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.vendor=GrupoIsonor
odoo.version=${{ matrix.version }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Push
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: ./${{ matrix.version }}.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Attest build provenance
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build-and-push.outputs.digest }}
push-to-registry: true