Skip to content

Commit

Permalink
added gh actions and pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
arihant2math committed May 26, 2023
1 parent cc3dd09 commit f17a750
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 7 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/[email protected]
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install Dependencies
run: pip install sphinx furo
- name: Build
run: sphinx-build -b html source build
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload build/ repository
path: 'build'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# 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.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "spacelang"
version = "0.0.0"
authors = [
{ name="Ashwin Naren", email="[email protected]" },
]
description = "A spacetraders automation language"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"autotraders >= 1.1",
"pyyaml >= 6.0",
]

[tool.setuptools.packages.find]
include = ["spacelang*"]
exclude = ["source*", "tests*", "venv*"]

[project.urls]
"Homepage" = "https://arihant2math.github.io/spacelang/"
"Documentation" = "https://arihant2math.github.io/spacelang/"
"Bug Tracker" = "https://github.com/arihant2math/spacelang/issues"
9 changes: 7 additions & 2 deletions spacelang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, name, data):
for d in data[group]["steps"]:
self.steps[group] = []
if type(d) == str:
self.steps[group].append(Step(d, None)) # TODO: Move to step class
self.steps[group].append(Step(d, None)) # TODO: Move to step class
else:
self.steps[group].append(Step(list(d.keys())[0], d[list(d.keys())[0]]))

Expand Down Expand Up @@ -68,7 +68,7 @@ def run(self, session):
if contains_onstart:
on_start = [trigger for trigger in self.triggers if trigger.name == "on_start"][0]
logging.info("Processing trigger on_start")
thread = Thread(target=on_start.run, name="on_start", args=(ships, self.events, session))
thread = Thread(target=on_start.run, name="OnStart", args=(ships, self.events, session))
thread.start()
while True:
logging.debug("Checking triggers ...")
Expand All @@ -79,3 +79,8 @@ def run(self, session):
def load_text(stream):
data = yaml.load(stream, Loader=yaml.Loader)
return data


logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.basicConfig(format='[%(threadName)s] %(levelname)s: %(message)s', level=logging.DEBUG)
5 changes: 0 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import logging

import secret
from spacelang import File, load_text
from autotraders import session as s

if __name__ == "__main__":
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.basicConfig(format='[%(threadName)s] %(levelname)s: %(message)s', level=logging.DEBUG)
File(load_text(open("example.yml"))).run(s.get_session(secret.TOKEN))

0 comments on commit f17a750

Please sign in to comment.