Skip to content
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
29 changes: 29 additions & 0 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,33 @@ jobs:
with:
user: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
builder: python
package: .
target: ghcr.io/syspack/pakages/pakages-bundle:latest

test-action-spack:
name: Test Spack Build Action
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Pakages
run: pip install -e .[all]

- name: Install Spack
run: |
git clone --depth 1 https://github.com/spack/spack /opt/spack
echo "/opt/spack/bin" >> $GITHUB_PATH
export PATH="/opt/spack/bin:$PATH"
spack external find

- name: Test Pakages Spack Build
uses: ./action/build
with:
user: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
builder: spack
package: zlib
repo: ./tests/spack
target: ghcr.io/syspack/pakages/test-zlib:latest
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pip. Only major versions will be released as tags on Github.

## [0.0.x](https://github.scom/syspack/pakages/tree/main) (0.0.x)
- updates to spack build (0.0.17)
- adding multiprocessing workers (0.0.16)
- tweaking install process (0.0.15)
- refactoring artifact extraction to allow reuse (0.0.14)
Expand Down
23 changes: 12 additions & 11 deletions action/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ name: "pakages build"
description: "Build oras pakages"
inputs:
builder:
description: the builder to use (defaults to auto-detect)
default: ""
description: the builder to use
required: true
user:
default: username to authenticate to GitHub packages
required: true
token:
default: token authenticate to GitHub packages
required: true
path:
description: path to root of package (defaults to PWD)
package:
description: package to build
required: true
repo:
description: filesystem path to repo to add (with repo.yaml)
default: "."
target:
description: target to upload to (defaults to GitHub repository)
Expand All @@ -26,24 +29,22 @@ runs:
which pakages || (
git clone https://github.com/syspack/pakages
cd pakages
pip install -e .
pip install -e .[all]
)

- name: Build Package
env:
ORAS_USER: ${{ inputs.user }}
ORAS_PASS: ${{ inputs.token }}
repo: ${{ inputs.repo }}
builder: ${{ inputs.builder }}
path: ${{ inputs.path }}
package: ${{ inputs.package }}
target: ${{ inputs.target }}
run: |
cmd="pakages build"
if [[ "${builder}" != "" ]]; then
cmd="${cmd} -b ${builder}"
fi
cmd="pakages build ${path}"
cmd="pakages build --builder ${builder} ${repo} ${package}"
if [[ "${target}" != "" ]]; then
cmd="${cmd} --push ${target}"
fi
echo ${cmd}
$cmd
shell: bash
2 changes: 1 addition & 1 deletion docs/getting_started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set of tested software.
If you have any questions or issues, please `let us know <https://github.com/syspack/pakages/issues>`_

.. toctree::
:maxdepth: 2
:maxdepth: 3

installation
settings
Expand Down
107 changes: 107 additions & 0 deletions docs/getting_started/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,110 @@ oras is in the container to easily pull and push packages:


And then you can interact with ``pakages`` as needed. We will be updated these docs with more soon!


GitHub Action
-------------

You can use one of our GitHub actions to build (and optionally deploy the build cache)
to GitHub packages.

Build
^^^^^

Here is an example for a python package:

.. code-block:: yaml

name: Test Python Build Action

on:
pull_request: []

jobs:
test-action:
name: Test Build Action
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Test Pakages Python Build
uses: syspack/packages/action/build@main
with:
user: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
builder: python
package: .
target: ghcr.io/syspack/pakages/pakages-bundle:latest


And for a spack package:

.. code-block:: yaml

name: Test Spack Build Action

on:
pull_request: []

jobs:
test-action-spack:
name: Test Spack Build Action
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Spack
run: |
git clone --depth 1 https://github.com/spack/spack /opt/spack
echo "/opt/spack/bin" >> $GITHUB_PATH
export PATH="/opt/spack/bin:$PATH"
spack external find

- name: Test Pakages Spack Build
uses: ./action/build
with:
user: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
builder: spack
repo: ./tests/spack
package: flux-core
target: ghcr.io/syspack/pakages-test/zlib:latest

Note that the main difference is that for the second we are installing spack
and asking for the spack builder. Also note that if you want to install a custom
branch of pakages beforhand, it will be used instead of instaling from main
by default.

The following variables are available:

.. list-table:: GitHub Action Variables
:widths: 25 65 10
:header-rows: 1

* - Name
- Description
- Default
* - builder
- The builder to use (e.g, spack)
- unset
* - package
- package name to build (required)
- unset
* - repo
- filesystem path to repo to add (with your package recipe)
- . (PWD)
* - target
- target to upload to (defaults to GitHub repository)
- unset
* - user
- username to authenticate GitHub packages
- unset (required)
* - token
- token to authenticate GitHub packages
- unset (required)


For an example, see `flux-framework/flux-spack <https://github.com/flux-framework/flux-spack>`_.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Resources
:caption: Getting started
:name: getting_started
:hidden:
:maxdepth: 2
:maxdepth: 3

getting_started/index
getting_started/user-guide
Expand Down
2 changes: 2 additions & 0 deletions pakages/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def get_package(root):
"""
Get a packager based on a context
"""
if isinstance(root, list):
root = root[0]
if os.path.exists(root):
if PythonPackage.matches(root):
return PythonPackage(root)
Expand Down
5 changes: 3 additions & 2 deletions pakages/builders/spack/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def create(self, specs, key=None):
if key:
command += ["-k", key]
command += ["-d", self.cache_dir, specs]
logger.info(command)
for line in pakages.utils.stream_command(command):
logger.info(line.strip("\n"))

Expand Down Expand Up @@ -126,8 +127,8 @@ def push(self, uri=None, tag=None):
if not self.spec:
logger.exit(f"Cannot find spec for {self.spec_name} in cache.")

suffix = self.get_spec_uri()
uri = f"{uri}/{suffix}"
if not uri:
uri = self.get_spec_uri()
if ":" not in uri:
uri = f"{uri}:{tag}"

Expand Down
22 changes: 13 additions & 9 deletions pakages/builders/spack/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import spack.config

import re
import shlex
import os
import json

Expand All @@ -30,6 +31,9 @@ def parse_package_request(self, packages):
# By defualt, assume not adding a repository
repo = None

if not isinstance(packages, list):
packages = shlex.split(packages)

# Case 1: we have an install directed at the present working directory
if packages and packages[0] == ".":
repo = os.getcwd()
Expand All @@ -39,21 +43,17 @@ def parse_package_request(self, packages):
if packages and os.path.exists(packages[0]):
repo = packages.pop(0)

# OR if we have a github URI
# OR if we have a github URI TODO, can clone here
if packages and re.search("(http|https)://github.com", packages[0]):
repo = packages.pop(0)

# Add the repository, if defined
if repo:
repo = pakages.spack.repo.PakRepo(repo)

# If we don't have packages and we have a repo, derive from PWD
if repo and not packages:
packages = repo.list_packages()
packages = os.listdir(repo)

# Finally, add the repository
if repo:
self.add_repository(repo.repo_dir)
self.add_repository(repo)

return packages

Expand Down Expand Up @@ -91,6 +91,7 @@ def parse_packages(self, packages):
"""
Helper function to ensure we return consistent names.
"""
packages = self.parse_package_request(packages)
if isinstance(packages, list):
packages = packages[0]
if " " in packages:
Expand All @@ -107,8 +108,11 @@ def add_repository(self, path):
pakages.repo.PakRepo first.
"""
repos = spack.config.get("repos")
repos.insert(0, path)
spack.config.set("repos", repos)
if path not in repos:
logger.info(f"Adding repo {path} to spack repos.")
repos.insert(0, path)
spack.config.set("repos", repos)
logger.info(f"Spack repos {repos}")

def download_cache(self, target, download_dir=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion pakages/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_parser():
action="store_true",
help="Given that --push is added, don't clean up the build cache.",
)
build.add_argument("packages", help="install these packages", nargs="?")
build.add_argument("packages", help="install these packages", nargs="+")

config = subparsers.add_parser(
"config",
Expand Down
3 changes: 1 addition & 2 deletions pakages/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def get_client(builder=None, settings_file=None):
from pakages.builders.spack import SpackClient

return SpackClient(settings_file=settings_file)
else:
return PakagesClient(settings_file=settings_file)
return PakagesClient(settings_file=settings_file)


class PakagesClient:
Expand Down
2 changes: 1 addition & 1 deletion pakages/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat and Alec Scott"
__license__ = "Apache-2.0"

__version__ = "0.0.16"
__version__ = "0.0.17"
AUTHOR = "Vanessa Sochat, Alec Scott"
NAME = "pakages"
PACKAGE_URL = "https://github.com/syspack/pakages"
Expand Down
24 changes: 24 additions & 0 deletions tests/spack/packages/zlib/configure-cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 05796d3d8d5546cf1b4dfe2cd72ab746afae505d Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Mon, 28 Mar 2022 18:34:10 -0700
Subject: [PATCH] Fix configure issue that discarded provided CC definition.

---
configure | 3 +++
1 file changed, 3 insertions(+)

diff --git a/configure b/configure
index 52ff4a04e..3fa3e8618 100755
--- a/configure
+++ b/configure
@@ -174,7 +174,10 @@ if test -z "$CC"; then
else
cc=${CROSS_PREFIX}cc
fi
+else
+ cc=${CC}
fi
+
cflags=${CFLAGS-"-O3"}
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
case "$cc" in
Loading