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

General update #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
!scripts
!README.md
!LICENSE
!MANIFEST.in
!src
!wheels

Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish package

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
bash scripts/install-system-packages.sh
bash scripts/setup-virtualenv.sh
- name: Build a binary wheel and a source tarball
run: poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
# - name: Publish package
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}

publish-to-pypi:
name: Publish distribution to PyPI
# only publish to PyPI on tag pushes
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/synthetic-ai
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python distribution with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
33 changes: 0 additions & 33 deletions .github/workflows/python-package.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/python-publish.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Run PyTest

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
pytest_image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker Image
run: docker build -t sai:latest -f Dockerfile .
- name: Run PyTest in Docker Image
run: |
export LOCAL_USER=$(whoami)
export LOCAL_USER_ID=$(id -u)
export PYTHON=/sai/bin/python
docker run --rm --volume ${PWD}:/workdir -e PYTHON -e LOCAL_USER_ID -e LOCAL_USER -t sai:latest bash scripts/pytest.sh

pytest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and test
run: |
sudo bash scripts/install-system-packages.sh
pip install --upgrade pip virtualenv
virtualenv sai
source "sai/bin/activate"
make install
make pytest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build/
.pytest_cache
.mypy_cache
.coverage
.coverage.*
.coverage*
.testmon*
pytest_artifacts

Expand Down
35 changes: 0 additions & 35 deletions .gitlab-ci.yml

This file was deleted.

28 changes: 3 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,15 @@ ENV PROJECT_NAME=$project_name

# Create workdir and copy dependency files
RUN mkdir -p /workdir
COPY pyproject.toml /workdir/pyproject.toml
COPY Makefile /workdir/Makefile
COPY scripts /workdir/scripts
COPY README.md /workdir/README.md
COPY LICENSE /workdir/LICENSE
COPY MANIFEST.in /workdir/MANIFEST.in
COPY src /workdir/src
COPY poetry.lock /workdir/
COPY . /workdir

# Change shell to be able to easily activate virtualenv
SHELL ["/bin/bash", "-c"]
WORKDIR /workdir

# Install project
RUN umask 022 && apt-get update \
# Install system packages
&& apt-get install -y --no-install-recommends apt-utils ca-certificates gosu sudo git rustc curl tree \
&& curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& source "$HOME/.cargo/env" \
&& rm -rf /var/lib/apt/lists/* \
# For debugging
&& tree . \
# Install Python dependencies
&& pip install virtualenv \
&& virtualenv "/$PROJECT_NAME" \
&& source "/$PROJECT_NAME/bin/activate" \
&& make install \
&& cp poetry.lock /tmp/. \
&& rm -r /root/.cache \
# Avoid permission problems: this is where the virtual env is installed in the image
&& chmod -R 777 "/$PROJECT_NAME"
RUN bash scripts/install-system-packages.sh && \
bash scripts/setup-virtualenv.sh

# TensorBoard
EXPOSE 6006
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

27 changes: 7 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export $(shell sed 's/=.*//' .env)
LOCAL_USER:=$(shell whoami)
LOCAL_USER_ID:=$(shell id -u)
# project
PROJECT_NAME?=sdata
PROJECT_NAME?=sai
# python
PYTHON?=python
PYTHON_EXEC?=python -m
Expand Down Expand Up @@ -45,43 +45,30 @@ BUILD_CMD=$(DOCKER) build -t $(REGISTRY)/$(PROJECT_NAME) --build-arg project_nam
# -----------
# install project's dependencies
# -----------
# dev dependencies
install-init:
$(PYTHON_EXEC) pip install --upgrade pip
$(PYTHON_EXEC) pip install --upgrade setuptools virtualenv poetry setuptools_rust
$(PYTHON_EXEC) pip install --upgrade poetry setuptools virtualenv setuptools_rust

# install main dependencies with poetry (dynamic installation)
install-w-poetry:
install: install-init
$(PYTHON_EXEC) $(POETRY) install --no-cache

poetry-lock:
nohup poetry lock 2>&1 > logs/poetry-lock.log &

# MAIN: w poetry (dynamic): install dev deps, then main deps, export frozen, then project
poetry-install: install-init
poetry-install: install-w-poetry

# MAIN: default installation method
install: poetry-install

install-nohup:
mkdir -p logs || echo "Folder already exists."
nohup make install 2>&1 > logs/install.log &


# -----------
# testing
# -----------
pytest:
bash scripts/pytest.sh

test: pytest


# ---
# git
# ---
# squash all commits before rebasing, see https://stackoverflow.com/questions/25356810/git-how-to-squash-all-commits-on-branch
git-squash: BRANCH=main
git-squash:
git reset $(git merge-base main $(git branch --show-current))
git reset $(shell git merge-base $(BRANCH) $(shell git branch --show-current))
git add -A
git commit -m "squashed commit"

Expand Down
Loading
Loading