-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add hack directory with pipeline scripts Co-authored-by: rtorrero <[email protected]> * Add suse packaging Dockerfile Co-authored-by: rtorrero <[email protected]> * Add OBS commit step in pipeline Co-authored-by: rtorrero <[email protected]> * Rename gh docker image from `wanda` to `trento-wanda` for consistency with web Co-authored-by: rtorrero <[email protected]>
- Loading branch information
1 parent
8696305
commit 05309af
Showing
6 changed files
with
228 additions
and
3 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 |
---|---|---|
|
@@ -20,6 +20,10 @@ jobs: | |
name: Elixir dependencies | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -70,6 +74,10 @@ jobs: | |
needs: elixir-deps | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -126,6 +134,10 @@ jobs: | |
ports: | ||
- 5674:5672 | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -159,22 +171,22 @@ jobs: | |
packages: write | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_REPOSITORY: ghcr.io/${{ github.repository_owner }}/wanda | ||
IMAGE_REPOSITORY: ghcr.io/${{ github.repository_owner }}/trento-wanda | ||
IMAGE_TAG: "${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'push' && github.ref_name == 'main' && 'rolling') || github.sha }}" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: docker/setup-buildx-action@v2 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a | ||
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 | ||
with: | ||
images: ${{ env.IMAGE_REPOSITORY }} | ||
- name: Build and push container image | ||
|
@@ -221,3 +233,77 @@ jobs: | |
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./doc | ||
|
||
obs-commit: | ||
name: Commit the project on OBS | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch' | ||
needs: [static-code-analysis, test] | ||
container: | ||
image: ghcr.io/trento-project/continuous-delivery:main | ||
env: | ||
GITHUB_OAUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
DEST_FOLDER: "/tmp/osc_project" | ||
NAME: trento-wanda-image | ||
OBS_USER: ${{ secrets.OBS_USER }} | ||
OBS_PASS: ${{ secrets.OBS_PASS }} | ||
OBS_PROJECT: ${{ secrets.OBS_PROJECT }} | ||
FOLDER: packaging/suse | ||
REPOSITORY: ${{ github.repository }} | ||
options: -u 0:0 | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: actions-ecosystem/action-get-latest-tag@v1 | ||
id: latest-tag | ||
with: | ||
semver_only: true | ||
initial_version: 0.0.1 | ||
- name: Setup rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: 1.66 | ||
- name: Get mix deps | ||
run: mix local.hex --force && mix local.rebar --force && mix deps.clean --all && mix deps.get | ||
- name: cargo vendor | ||
run: | | ||
cd deps/rhai_rustler/native/rhai_rustler | ||
cargo vendor | ||
printf '\n\n[source.crates-io]\nreplace-with = "vendored-sources"\n\n[source.vendored-sources]\ndirectory = "vendor"\n' >> .cargo/config | ||
- name: Configure OSC | ||
# OSC credentials must be configured beforehand as the HOME variables cannot be changed from /github/home | ||
# that is used to run osc commands | ||
run: | | ||
mkdir -p $HOME/.config/osc | ||
cp /home/osc/.config/osc/oscrc $HOME/.config/osc | ||
/scripts/init_osc_creds.sh | ||
- name: Prepare .changes file | ||
# The .changes file is updated only in release creation. This current task should be improved | ||
# in order to add the current rolling release notes | ||
if: github.event_name == 'release' | ||
run: | | ||
CHANGES_FILE=$NAME.changes | ||
osc checkout $OBS_PROJECT $NAME $CHANGES_FILE | ||
mv $CHANGES_FILE $FOLDER | ||
VERSION=${{ steps.latest-tag.outputs.tag }} | ||
hack/gh_release_to_obs_changeset.py $REPOSITORY -a [email protected] -t $VERSION -f $FOLDER/$CHANGES_FILE | ||
- name: Set version | ||
run: | | ||
git config --global --add safe.directory /__w/wanda/wanda | ||
VERSION=$(./hack/get_version_from_git.sh) | ||
# "+" character is not allowed in OBS dockerfile version strings | ||
VERSION=${VERSION//[+]/-} | ||
sed -i 's~%%VERSION%%~'"${VERSION}"'~' packaging/suse/Dockerfile | ||
- name: Commit on OBS | ||
run: | | ||
OBS_PACKAGE=$OBS_PROJECT/$NAME | ||
osc checkout $OBS_PACKAGE -o $DEST_FOLDER | ||
cp -r packaging/suse/* $DEST_FOLDER | ||
tar --transform 's,^./,/wanda/,' -zcvf $DEST_FOLDER/wanda.tar.gz --exclude=./.git ./* | ||
cd $DEST_FOLDER | ||
osc ar | ||
osc commit -m "New development version of $NAME released" |
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,17 @@ | ||
#!/bin/sh | ||
set -e | ||
set -o pipefail | ||
|
||
TAG=$( git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1 ) | ||
|
||
if [ -n "${TAG}" ]; then | ||
COMMITS_SINCE_TAG=$(git rev-list "${TAG}".. --count) | ||
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then | ||
COMMIT_SHA=$(git show -s --format=%ct.%h HEAD) | ||
SUFFIX="+git.dev${COMMITS_SINCE_TAG}.${COMMIT_SHA}" | ||
fi | ||
else | ||
TAG="0" | ||
fi | ||
|
||
echo "${TAG}${SUFFIX}" |
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,79 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import json | ||
import os | ||
import sys | ||
import textwrap | ||
import urllib.request | ||
import urllib.error | ||
from datetime import datetime | ||
from datetime import timezone | ||
import tempfile | ||
|
||
parser = argparse.ArgumentParser(description="Add a GitHub release to an RPM changelog", usage=argparse.SUPPRESS) | ||
parser.add_argument("repo", help="GitHub repository (owner/name)") | ||
parser.add_argument("-t", "--tag", help="A specific Git tag to get; if none, latest will be used") | ||
parser.add_argument("-a", "--author", help="The author of the RPM changelog entry") | ||
parser.add_argument("-f", "--file", help="Prepend the new changelog entry to file instead of printing in stdout") | ||
|
||
if len(sys.argv) == 1: | ||
parser.print_help(sys.stderr) | ||
sys.exit(1) | ||
|
||
args = parser.parse_args() | ||
|
||
releaseSegment = f"/tags/{args.tag}" if args.tag else "/latest" | ||
url = f'https://api.github.com/repos/{args.repo}/releases{releaseSegment}' | ||
|
||
request = urllib.request.Request(url) | ||
|
||
githubToken = os.getenv("GITHUB_OAUTH_TOKEN") | ||
if githubToken: | ||
request.add_header("Authorization", "token " + githubToken) | ||
|
||
try: | ||
response = urllib.request.urlopen(request) | ||
except urllib.error.HTTPError as error: | ||
if error.code == 404: | ||
print(f"Release {args.tag} not found in {args.repo}. Skipping changelog generation.") | ||
sys.exit(0) | ||
print(f"GitHub API responded with a {error.code} error!", file=sys.stderr) | ||
print("Url:", url, file=sys.stderr) | ||
print("Response:", json.dumps(json.load(error), indent=4), file=sys.stderr, sep="\n") | ||
sys.exit(1) | ||
|
||
release = json.load(response) | ||
|
||
releaseDate = datetime.strptime(release['published_at'], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc) | ||
|
||
with tempfile.TemporaryFile("r+") as temp: | ||
print("-------------------------------------------------------------------", file=temp) | ||
|
||
print(f"{releaseDate.strftime('%a %b %d %H:%M:%S %Z %Y')}", end="", file=temp) | ||
if args.author: | ||
print(f" - {args.author}", end="", file=temp) | ||
print("\n", file=temp) | ||
|
||
print(f"- Release {args.tag}", end="", file=temp) | ||
if release['name'] and release['name'] != args.tag: | ||
print(f" - {release['name']}", end="", file=temp) | ||
print("\n", file=temp) | ||
|
||
if release['body']: | ||
print(textwrap.indent(release['body'], " "), file=temp, end="\n\n") | ||
temp.seek(0) | ||
|
||
if args.file: | ||
try: | ||
with open(args.file, "r") as prev: | ||
old = prev.read() | ||
except FileNotFoundError: | ||
old = "" | ||
with open(args.file, "w") as new: | ||
for line in temp: | ||
new.write(line) | ||
new.write(old) | ||
sys.exit(0) | ||
|
||
print(temp.read()) |
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,32 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
#!BuildTag: trento/trento-wanda:latest | ||
#!BuildTag: trento/trento-wanda:%%VERSION%% | ||
#!BuildTag: trento/trento-wanda:%%VERSION%%-build%RELEASE% | ||
#!UseOBSRepositories | ||
|
||
FROM bci/rust:1.66 AS release | ||
ADD wanda.tar.gz /build/ | ||
# Workaround for https://github.com/openSUSE/obs-build/issues/487 | ||
RUN zypper --non-interactive in sles-release | ||
RUN zypper -n in elixir elixir-hex erlang-rebar3 | ||
WORKDIR /build/wanda/ | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
ENV MIX_ENV=prod | ||
ENV MIX_HOME=/usr/bin | ||
ENV VERSION=%%VERSION%% | ||
RUN mix phx.digest | ||
RUN mix release | ||
|
||
FROM bci/rust:1.66 AS wanda | ||
# Define labels according to https://en.opensuse.org/Building_derived_containers | ||
# labelprefix=com.suse.trento | ||
LABEL org.opencontainers.image.source="https://github.com/trento-project/wanda" | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
WORKDIR /app | ||
COPY --from=release /build/wanda/_build/prod/rel/wanda . | ||
EXPOSE 4000/tcp | ||
ENTRYPOINT ["/app/bin/wanda"] |
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,7 @@ | ||
<constraints> | ||
<hardware> | ||
<disk> | ||
<size unit="G">8</size> | ||
</disk> | ||
</hardware> | ||
</constraints> |
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,4 @@ | ||
<services> | ||
<service mode="buildtime" name="docker_label_helper"/> | ||
<service mode="buildtime" name="kiwi_metainfo_helper"/> | ||
</services> |