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

Feature/ci #1

Merged
merged 1 commit into from
Feb 24, 2024
Merged
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
76 changes: 76 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '24 3 * * 6'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
46 changes: 46 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
pull_request:
branches: [ "master" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
if: '! github.event.pull_request.draft'
runs-on: ${{ matrix.os }}

strategy:
matrix:
python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ]
os: [ ubuntu-latest, macos-latest ]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
run: |
python -m pip install flake8
flake8 . --max-line-length=127
- name: Verify sorted imports
run: |
python -m pip install isort
isort . -m HANGING_INDENT -l 120 --check-only
- name: Test install
run: |
python -m pip install --upgrade pip
python -m pip install -U .
- name: Test
run: |
c-struct "struct dirent"
c-struct "struct dirent" d_ino
c-const EAGAIN
29 changes: 29 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [ created ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U build setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
twine upload dist/*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
._DS_Store
.DS_Store
.idea
dist
*.egg_info
Expand Down
28 changes: 12 additions & 16 deletions c_helpers/__main__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import os
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Optional

import click
from pathlib import Path

from plumbum import local

clang = local['clang']

SUFFIX = '.mm' if os.uname().sysname == 'Darwin' else '.cpp'

HEADERS = ['stdio.h',
'unistd.h',
'errno.h',
'sys/socket.h',
'sys/stat.h',
'sys/types.h',
'sys/dir.h',
'sys/dirent.h',
'dlfcn.h',
'sys/utsname.h',
'resolv.h',
'AppleArchive/AADefs.h']
HEADERS = ['stdio.h', 'unistd.h', 'errno.h', 'sys/socket.h', 'sys/stat.h', 'sys/types.h', 'sys/dir.h',
'dlfcn.h', 'sys/utsname.h', 'resolv.h', ]

if os.uname().sysname == 'Darwin':
HEADERS += ['sys/dirent.h', 'AppleArchive/AADefs.h', ]
else:
HEADERS += ['dirent.h', ]

FRAMEWORKS = ['Foundation', 'CoreFoundation', 'SystemConfiguration', 'CoreGraphics', 'CoreImage']

C_STRUCT_MEMBER_FORMAT = r'''
Expand All @@ -32,8 +27,9 @@
printf("{highlight}sizeof({name}): {default}%lu (0x%.2x)\n\
{highlight}offsetof({name}, {member}): {default}%lu (0x%.2x)\n\
{highlight}sizeof({name}::{member}): {default}%lu (0x%.2x)", \
sizeof(var), sizeof(var), __builtin_offsetof({name}, {member}), __builtin_offsetof({name}, {member}), sizeof(var.{member}), sizeof(var.{member}));
sizeof(var), sizeof(var), __builtin_offsetof({name}, {member}), __builtin_offsetof({name}, {member}), \
sizeof(var.{member}), sizeof(var.{member}));
return 0;
}}
'''
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
click
plumbum
Loading