Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add 'dev.py' #19

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .containerignore
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@
!/LICENSE.txt
!/Makefile
!/README.md
!/dev.py
!/dev.txt
!/dev/
!/go.mod
!/go.sum
!/internal
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
@@ -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
@@ -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/mockgen@v0.3.0
- 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
@@ -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/mockgen@v0.3.0
- 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
@@ -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",
18 changes: 15 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -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 \
@@ -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 \
@@ -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

Loading
Loading