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
10 changes: 10 additions & 0 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ jobs:
package: zlib
repo: ./tests/spack
target: ghcr.io/syspack/pakages/test-zlib:latest

- name: Test Pakages Spack Install
uses: ./action/install
with:
user: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
builder: spack
package: zlib
repo: ./tests/spack
use_cache: ghcr.io/syspack/pakages/test-zlib:latest
3 changes: 1 addition & 2 deletions .github/workflows/test-spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ jobs:
run: |
git clone --depth 1 https://github.com/spack/spack /tmp/spack
pip install -e .[all]
pip install git+https://github.com/oras-project/oras-py.git@improve-403-error-message


- name: List Files
run: ls .
- name: Build and Deploy Spack Package
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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)
- bugfixes to install and adding GitHub action (0.0.18)
- checking for existing mirrors before adding blindly
- updates to spack build (0.0.17)
- adding multiprocessing workers (0.0.16)
- tweaking install process (0.0.15)
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ RUN curl -LO https://github.com/oras-project/oras/releases/download/v0.12.0/oras
COPY ./entrypoint.sh /entrypoint.sh
WORKDIR /opt/pakages
COPY . /opt/pakages
RUN python3 -m pip install . && \
python3 -m pip install git+https://github.com/oras-project/oras-py.git@improve-403-error-message

RUN python3 -m pip install .
ENV SPACK_ROOT=/opt/spack
ENTRYPOINT ["/bin/bash"]
50 changes: 50 additions & 0 deletions action/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "pakages install"
description: "Install with pakages"
inputs:
user:
default: username to authenticate to GitHub packages
required: true
token:
default: token authenticate to GitHub packages
required: true
builder:
description: the builder to use
required: true
package:
description: package to install
required: true
repo:
description: filesystem path to repo to add (with repo.yaml)
default: "."
use_cache:
description: target of previous build cache to install from
default: ""

runs:
using: "composite"
steps:
- name: Install Pakages
shell: bash
run: |
which pakages || (
git clone https://github.com/syspack/pakages
cd pakages
pip install -e .[all]
)

- name: Install Package
env:
ORAS_USER: ${{ inputs.user }}
ORAS_PASS: ${{ inputs.token }}
repo: ${{ inputs.repo }}
use_cache: ${{ inputs.use_cache }}
builder: ${{ inputs.builder }}
package: ${{ inputs.package }}
run: |
cmd="pakages install --builder ${builder} ${repo} ${package}"
if [[ "${use_cache}" != "" ]]; then
cmd="${cmd} --use_cache ${use_cache}"
fi
echo ${cmd}
$cmd
shell: bash
66 changes: 66 additions & 0 deletions docs/getting_started/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,72 @@ GitHub Action
You can use one of our GitHub actions to build (and optionally deploy the build cache)
to GitHub packages.

Install
^^^^^^^

An install simply installs (and optionally from a build cache already done).
Unlike build, it doesn't then create a build cache.

.. 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 Install
uses: syspack/pakages/action/install@main
with:
builder: spack
package: zlib
repo: ./tests/spack
use_cache: ghcr.io/syspack/pakages/test-zlib:latest


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)
* - use_cache
- target (GitHub Package) to install from
- unset
* - user
- username to authenticate GitHub packages
- unset (required)
* - token
- token to authenticate GitHub packages
- unset (required)


Build
^^^^^

Expand Down
7 changes: 4 additions & 3 deletions pakages/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat and Alec Scott"
__license__ = "Apache-2.0"

from pakages.logger import logger
import pakages.oras
import shutil
import os
import shutil

import pakages.oras
from pakages.logger import logger


class BuildResult:
Expand Down
6 changes: 4 additions & 2 deletions pakages/builders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from .python import PythonPackage
from pakages.logger import logger
import os

from pakages.logger import logger

from .python import PythonPackage


def get_package(root):
"""
Expand Down
18 changes: 9 additions & 9 deletions pakages/builders/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat and Alec Scott"
__license__ = "Apache-2.0"

import pakages.utils as utils
import pakages.build
from pakages.logger import logger
from citelang.main.packages import SetupManager
import os
import shutil

from cyclonedx_py.parser.requirements import RequirementsParser
from cyclonedx.model.bom import Bom
from cyclonedx.output import get_instance, OutputFormat
from citelang.main.packages import SetupManager
from cyclonedx.model import Tool
from cyclonedx.model.bom import Bom
from cyclonedx.output import OutputFormat, get_instance
from cyclonedx_py.parser.requirements import RequirementsParser

import pakages.build
import pakages.utils as utils
from pakages.logger import logger
from pakages.version import __version__ as version
import shutil
import os


class PythonPackage:
Expand Down
18 changes: 13 additions & 5 deletions pakages/builders/spack/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat and Alec Scott"
__license__ = "Apache-2.0"

from pakages.logger import logger
import pakages.utils
import os
import shutil

import spack.config

import pakages.build
import pakages.defaults
import pakages.settings

import shutil
import os
import pakages.utils
from pakages.logger import logger


class BuildCache:
Expand Down Expand Up @@ -55,6 +57,12 @@ def add_as_mirror(self, name):
["spack", "buildcache", "update-index", "-d", self.cache_dir],
["spack", "buildcache", "list", "--allarch"],
]

# Cut out early if mirror already added
mirrors = spack.config.get("mirrors")
if name not in mirrors:
return

for command in commands:
try:
for line in pakages.utils.stream_command(command):
Expand Down
25 changes: 14 additions & 11 deletions pakages/builders/spack/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat and Alec Scott"
__license__ = "Apache-2.0"

from pakages.logger import logger
import pakages.builders.spack.cache as spack_cache
import pakages.client
import pakages.oras
import json
import os
import re
import shlex

import spack.cmd
import spack.target
import spack.main
import spack.config
import spack.main
import spack.target

import re
import shlex
import os
import json
import pakages.builders.spack.cache as spack_cache
import pakages.client
import pakages.oras
from pakages.logger import logger


class SpackClient(pakages.client.PakagesClient):
Expand Down Expand Up @@ -144,7 +144,10 @@ def install(self, packages, **kwargs):
command = ["spack", "install"]
if use_cache:
command.append("--use-cache")
command.append(" ".join(packages))
if isinstance(packages, list):
command.append(" ".join(packages))
else:
command.append(packages)

# Install packages using system spack - we aren't responsible for this working
for line in pakages.utils.stream_command(command):
Expand Down
11 changes: 6 additions & 5 deletions pakages/builders/spack/sbom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

# https://www.ntia.gov/files/ntia/publications/howto_guide_for_sbom_generation_v1.pdf

import pakages.utils
import spack.main
import os
import uuid
from datetime import datetime

import spack.config
import spack.main
import spack.spec

from datetime import datetime
import uuid
import os
import pakages.utils

# We will use CycloneDX which is a simplified format approved by standards committees
# https://cyclonedx.org/docs/1.3/json
Expand Down
3 changes: 2 additions & 1 deletion pakages/builders/spack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import os
import sys
from pakages.utils.terminal import get_installdir, which, run_command

from pakages.utils.terminal import get_installdir, run_command, which


def generalize_spack_archive(name):
Expand Down
12 changes: 7 additions & 5 deletions pakages/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat and Alec Scott"
__license__ = "Apache-2.0"

import pakages
from pakages.logger import setup_logger
import argparse
import sys
import os
import sys

import pakages
from pakages.logger import setup_logger


def get_parser():
Expand Down Expand Up @@ -64,7 +65,6 @@ def get_parser():
description="install to the current environment",
formatter_class=argparse.RawTextHelpFormatter,
)
install.add_argument("packages", help="install these packages", nargs="+")

build = subparsers.add_parser(
"build",
Expand Down Expand Up @@ -112,7 +112,6 @@ 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="+")

config = subparsers.add_parser(
"config",
Expand Down Expand Up @@ -175,6 +174,9 @@ def get_parser():
dest="tag",
help="tag to use for build cache retrieval or push",
)
command.add_argument(
"packages", help="build or install these packages", nargs="+"
)

return parser

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

from pakages.logger import logger
from pakages.client import get_client
from pakages.logger import logger


def main(args, parser, extra, subparser):
Expand Down
5 changes: 3 additions & 2 deletions pakages/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat and Alec Scott"
__license__ = "Apache-2.0"

from pakages.client import get_client
import sys

import pakages.defaults as defaults
from pakages.client import get_client
from pakages.logger import logger
import sys


def main(args, parser, extra, subparser):
Expand Down
Loading