-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-generate next version manifest(s) (#461)
* Auto-generate next version manifest. Signed-off-by: dblock <dblock@dblock.org> * Added GitHub Actions workflow. Signed-off-by: dblock <dblock@dblock.org> * Fixed pipenv run mypy . Signed-off-by: dblock <dblock@dblock.org> * Refactored manifest writing. Signed-off-by: dblock <dblock@dblock.org> * Moved file. Signed-off-by: dblock <dblock@dblock.org> * Extracted manifests and components. Signed-off-by: dblock <dblock@dblock.org> * Added unit tests for manifests_workflow. Signed-off-by: dblock <dblock@dblock.org> * Added --keep. Signed-off-by: dblock <dblock@dblock.org> * Documented manifests workflow. Signed-off-by: dblock <dblock@dblock.org> * Name the pull request branch. Signed-off-by: dblock <dblock@dblock.org> * Cache maven local dependencies. Signed-off-by: dblock <dblock@dblock.org> * Naming branch doesn't work. Signed-off-by: dblock <dblock@dblock.org>
- Loading branch information
Showing
25 changed files
with
3,321 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: versions | ||
|
||
on: | ||
push: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
env: | ||
PYTHON_VERSION: 3.7 | ||
JDK_VERSION: 14 | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set Up JDK ${{ env.JDK_VERSION }} | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ env.JDK_VERSION }} | ||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- name: Install Pipenv and Dependencies | ||
run: | | ||
python -m pip install --upgrade pipenv wheel | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-build-cache-maven-local | ||
- name: Update OpenSearch Manifests | ||
run: | | ||
./bundle-workflow/manifests.sh update | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
commit-message: Updated manifests. | ||
delete-branch: true | ||
title: '[AUTO] Updated input manifests.' | ||
body: | | ||
I've noticed that a repo has incremented a version and have made some updates to input manifests. | ||
- name: Check outputs | ||
run: | | ||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
set -e | ||
|
||
DIR="$(dirname "$0")" | ||
"$DIR/run.sh" "$DIR/src/manifests.py" $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import logging | ||
|
||
from manifests_workflow.input_manifests import InputManifests | ||
from manifests_workflow.manifests_args import ManifestsArgs | ||
from system import console | ||
|
||
args = ManifestsArgs() | ||
console.configure(level=args.logging_level) | ||
manifests = InputManifests() | ||
|
||
if args.action == "list": | ||
for manifest in manifests.values(): | ||
logging.info(f"{manifest.build.name} {manifest.build.version}") | ||
elif args.action == "update": | ||
manifests.update(keep=args.keep) | ||
|
||
logging.info("Done.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import glob | ||
import os | ||
import re | ||
|
||
from manifests.input_manifest import InputManifest | ||
from manifests.manifests import Manifests | ||
|
||
|
||
class InputManifests(Manifests): | ||
def __init__(self): | ||
files = glob.glob(os.path.join(self.manifests_path, "opensearch-*.yml")) | ||
# there's an opensearch-1.0.0-maven.yml that we want to skip | ||
files = [f for f in files if re.search(r"/opensearch-([0-9.]*)\.yml$", f)] | ||
super().__init__(InputManifest, files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import os | ||
import re | ||
|
||
from sortedcontainers import SortedDict # type: ignore | ||
|
||
|
||
class Manifests(SortedDict): | ||
def __init__(self, klass, files): | ||
super(Manifests, self).__init__() | ||
self.klass = klass | ||
self.__append__(files) | ||
|
||
def __append__(self, files): | ||
for filename in files: | ||
basename = os.path.basename(filename) | ||
match = re.search(r"-([0-9.]*).yml$", basename) | ||
if not match: | ||
raise ValueError(f"Invalid file: {basename}") | ||
|
||
version = match.group(1) | ||
manifest = self.klass.from_path(filename) | ||
self.__setitem__(version, manifest) | ||
|
||
@property | ||
def manifests_path(self): | ||
return os.path.realpath( | ||
os.path.join(os.path.dirname(__file__), "../../../manifests") | ||
) | ||
|
||
@property | ||
def versions(self): | ||
return list(map(lambda manifest: manifest.build.version, self.values())) | ||
|
||
@property | ||
def latest(self): | ||
if len(self) == 0: | ||
raise RuntimeError("No manifests found") | ||
|
||
return self.values()[-1] |
Oops, something went wrong.