Skip to content

Commit

Permalink
[WIP] Add 'dev.py'
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Hernandez <[email protected]>
  • Loading branch information
jhernand committed Feb 29, 2024
1 parent 8e230b2 commit a7ca9e7
Show file tree
Hide file tree
Showing 32 changed files with 1,390 additions and 413 deletions.
3 changes: 3 additions & 0 deletions .containerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
!/LICENSE.txt
!/Makefile
!/README.md
!/dev.py
!/dev.txt
!/dev/
!/go.mod
!/go.sum
!/internal
Expand Down
37 changes: 37 additions & 0 deletions .github/actions/install-tools/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright (c) 2023 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#

name: Install tools
runs:
using: composite
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
cache: pip
cache-dependency-path: dev.txt

- name: Install Python modules
shell: bash
run: pip install -r dev.txt

- name: Install tools
shell: bash
run: ./dev.py setup
49 changes: 15 additions & 34 deletions .github/workflows/check-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ jobs:
- name: Checkout the source
uses: actions/checkout@v3

- name: Install tools
uses: ./.github/actions/install-tools

- name: Build image
run: make image
run: ./dev.py build image

unit-tests:
name: Unit tests
Expand All @@ -38,25 +41,14 @@ jobs:
- name: Checkout the source
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install Go tools
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@$(go list -f '{{.Version}}' -m github.com/onsi/ginkgo/v2)
go install go.uber.org/mock/[email protected]
- name: Install tools
uses: ./.github/actions/install-tools

- name: Install spectral
run: |
curl -Lo spectral https://github.com/stoplightio/spectral/releases/download/v6.11.0/spectral-linux-x64
echo 0e151d3dc5729750805428f79a152fa01dd4c203f1d9685ef19f4fd4696fcd5f spectral | sha256sum -c
chmod +x spectral
sudo mv spectral /usr/bin
- name: Install tools
run: ./dev.py setup

- name: Run the tests
run: make tests
run: ./dev.py test

check-generated-code:
name: Check generated code
Expand All @@ -65,17 +57,11 @@ jobs:
- name: Checkout the source
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install Go tools
run: |
go install go.uber.org/mock/[email protected]
- name: Install tools
uses: ./.github/actions/install-tools

- name: Generate code
run: make generate
run: ./dev.py generate

- name: Check differences
run: git diff --exit-code
Expand All @@ -87,13 +73,8 @@ jobs:
- name: Checkout the source
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Install tools
uses: ./.github/actions/install-tools

- name: Run the linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
args: --timeout=5m
run: ./dev.py lint
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.log
*.pyc
/__debug*
/bin/*
/oran-o2ims
/vendor
/bin/*
__pycache__
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "setup",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/dev.py",
"args": [
"setup",
],
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "version",
"type": "go",
Expand Down
18 changes: 15 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@

FROM registry.access.redhat.com/ubi9/ubi:9.2 AS builder

# Install packages:
# Install OS packages:
RUN \
dnf install -y \
make \
python3.11 \
python3.11-pip \
&& \
dnf clean all

# In RHEL containers the default is Python 3.9, but we need the version of Python 3.11 that we
# installed as the default, otherwise our build scripts don't work correctly:
RUN \
ln -sf python3.11 /usr/bin/python3

# Currently RHEL 9 doesn't provide a Go 1.21 compiler, so we need to install it from the Go
# downloads site:
RUN \
Expand All @@ -39,6 +45,12 @@ WORKDIR \
ENV \
PATH="${PATH}:/usr/local/go/bin"

# Install Python packages:
COPY \
dev.txt .
RUN \
pip3.11 install -r dev.txt

# Copy the source:
COPY \
--chown=builder:builder \
Expand All @@ -51,7 +63,7 @@ RUN \

# Build the binary:
RUN \
make binary
./dev.py build binary

FROM registry.access.redhat.com/ubi9-minimal:9.2 AS runtime

Expand Down
Loading

0 comments on commit a7ca9e7

Please sign in to comment.