Skip to content

Commit

Permalink
Update GHA
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
fao89 committed Dec 10, 2020
1 parent dbdcfae commit 2faf078
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 53 deletions.
4 changes: 3 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ values =
dev
prod

[bumpversion:file:./pulp_npm/__init__.py]
[bumpversion:file:./pulp_npm/app/__init__.py]

[bumpversion:file:./setup.py]

[bumpversion:file:./docs/conf.py]
File renamed without changes.
4 changes: 3 additions & 1 deletion .ci/scripts/docs-builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ def main():

ga_build = False

if not re.search("[a-zA-Z]", branch) and len(branch.split(".")) > 2:
if (not re.search("[a-zA-Z]", branch) or "post" in branch) and len(branch.split(".")) > 2:
ga_build = True
if "post" in branch:
branch = ".".join(branch.split(".")[:-1])

# build the docs via the Pulp project itself
print("Building the docs")
Expand Down
32 changes: 20 additions & 12 deletions .ci/scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ def validate_redmine_data(redmine_query_url, redmine_issues):
release_path = os.path.dirname(os.path.abspath(__file__))
plugin_path = release_path.split("/.ci")[0]

version = {}
plugin_name = "pulp_npm"
with open(f"{plugin_path}/{plugin_name}/__init__.py") as fp:
version_line = [line for line in fp.readlines() if "__version__" in line][0]
exec(version_line, version)
release_version = version["__version__"].replace(".dev", "")
version = None
with open(f"{plugin_path}/setup.py") as fp:
for line in fp.readlines():
if "version=" in line:
version = line.split('"')[1]
if not version:
raise RuntimeError("Could not detect existing version ... aborting.")
release_version = version.replace(".dev", "")


issues_to_close = []
for filename in Path(f"{plugin_path}/CHANGES").rglob("*"):
Expand Down Expand Up @@ -155,7 +159,8 @@ def validate_redmine_data(redmine_query_url, redmine_issues):

os.system("bump2version release --allow-dirty")

git.add(f"{plugin_path}/{plugin_name}/__init__.py")
git.add(f"{plugin_path}/{plugin_name}/*")
git.add(f"{plugin_path}/docs/conf.py")
git.add(f"{plugin_path}/setup.py")
git.add(f"{plugin_path}/requirements.txt")
git.add(f"{plugin_path}/.bumpversion.cfg")
Expand All @@ -177,14 +182,17 @@ def validate_redmine_data(redmine_query_url, redmine_issues):

os.system(f"bump2version {release_type} --allow-dirty")

version = {}
with open(f"{plugin_path}/{plugin_name}/__init__.py") as fp:
version_line = [line for line in fp.readlines() if "__version__" in line][0]
exec(version_line, version)
new_dev_version = version["__version__"]
new_dev_version = None
with open(f"{plugin_path}/setup.py") as fp:
for line in fp.readlines():
if "version=" in line:
new_dev_version = line.split('"')[1]
if not new_dev_version:
raise RuntimeError("Could not detect new dev version ... aborting.")


git.add(f"{plugin_path}/{plugin_name}/__init__.py")
git.add(f"{plugin_path}/{plugin_name}/*")
git.add(f"{plugin_path}/docs/conf.py")
git.add(f"{plugin_path}/setup.py")
git.add(f"{plugin_path}/requirements.txt")
git.add(f"{plugin_path}/.bumpversion.cfg")
Expand Down
14 changes: 0 additions & 14 deletions .ci/scripts/secrets.py

This file was deleted.

3 changes: 0 additions & 3 deletions .github/.gitignore

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ jobs:
run: |
.github/workflows/scripts/before_script.sh
- name: Setting secrets
if: github.event_name != 'pull_request'
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}

- name: Script
run: .github/workflows/scripts/script.sh
shell: bash
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ jobs:
run: |
.github/workflows/scripts/before_script.sh
- name: Setting secrets
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}

- name: Script
run: .github/workflows/scripts/script.sh
shell: bash
Expand Down Expand Up @@ -114,7 +119,7 @@ jobs:
run: .github/workflows/scripts/before_script.sh

- name: Setting secrets
run: python3 .ci/scripts/secrets.py "$SECRETS_CONTEXT"
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
run: |
.github/workflows/scripts/before_script.sh
- name: Setting secrets
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}

- name: Script
run: .github/workflows/scripts/script.sh
shell: bash
Expand Down Expand Up @@ -114,7 +119,7 @@ jobs:
.github/workflows/scripts/before_script.sh
- name: Setting secrets
run: python3 .ci/scripts/secrets.py "$SECRETS_CONTEXT"
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
- name: Deploy plugin to pypi
Expand Down
25 changes: 9 additions & 16 deletions .github/workflows/scripts/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fi

cd ..

git clone https://github.com/pulp/pulp-openapi-generator.git
git clone --depth=1 https://github.com/pulp/pulp-openapi-generator.git
if [ -n "$PULP_OPENAPI_GENERATOR_PR_NUMBER" ]; then
cd pulp-openapi-generator
git fetch origin pull/$PULP_OPENAPI_GENERATOR_PR_NUMBER/head:$PULP_OPENAPI_GENERATOR_PR_NUMBER
Expand All @@ -91,24 +91,17 @@ cd ..



# When building a (release) tag, we don't need the development modules for the
# build (they will be installed as dependencies of the plugin).
if [ "${TAG_BUILD}" = "1" ]; then

git clone --depth=1 https://github.com/pulp/pulp-smash.git

if [ -n "$PULP_SMASH_PR_NUMBER" ]; then
cd pulp-smash
git fetch --depth=1 origin pull/$PULP_SMASH_PR_NUMBER/head:$PULP_SMASH_PR_NUMBER
git checkout $PULP_SMASH_PR_NUMBER
cd ..
fi

# pulp-smash already got installed via test_requirements.txt
pip install --upgrade --force-reinstall ./pulp-smash
git clone --depth=1 https://github.com/pulp/pulp-smash.git

if [ -n "$PULP_SMASH_PR_NUMBER" ]; then
cd pulp-smash
git fetch --depth=1 origin pull/$PULP_SMASH_PR_NUMBER/head:$PULP_SMASH_PR_NUMBER
git checkout $PULP_SMASH_PR_NUMBER
cd ..
fi

pip install --upgrade --force-reinstall ./pulp-smash


# Intall requirements for ansible playbooks
pip install docker netaddr boto3 ansible
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/scripts/secrets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import json
import os
import sys

secrets = json.loads(sys.argv[1])
for key, value in secrets.items():
print(f"Setting {key} ...")
lines = len(value.split("\n"))
if lines > 1:
os.system(f"/bin/bash -c \"echo '{key}<<EOF' >> $GITHUB_ENV\"")
os.system(f"/bin/bash -c \"echo '{value}' >> $GITHUB_ENV\"")
os.system("/bin/bash -c \"echo 'EOF' >> $GITHUB_ENV\"")
else:
os.system(f"/bin/bash -c \"echo '{key}={value}' >> $GITHUB_ENV\"")
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = pulp_npm.__version__
version = "0.1.0a3.dev"
# The full version, including alpha/beta/rc tags.
release = pulp_npm.__version__
release = "0.1.0a3.dev"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 0 additions & 2 deletions pulp_npm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
__version__ = "0.1.0a3.dev"

default_app_config = "pulp_npm.app.PulpNpmPluginAppConfig"
1 change: 1 addition & 0 deletions pulp_npm/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ class PulpNpmPluginAppConfig(PulpPluginAppConfig):

name = "pulp_npm.app"
label = "npm"
version = "0.1.0a3.dev"

0 comments on commit 2faf078

Please sign in to comment.