Apply to open source programs.

This commit is contained in:
Florian Anceau
2024-05-26 21:44:25 +00:00
parent 3cf6b608b2
commit 20e321d930
12 changed files with 251 additions and 53 deletions

View File

@@ -9,28 +9,35 @@ services:
- TARGET: [oldstable, stable, unstable]
stages:
- schedule
- build
- test
- release
before_script:
- apk add bash git curl jq make
include:
- template: Jobs/Code-Quality.gitlab-ci.yml
- template: Jobs/SAST.latest.gitlab-ci.yml
build:
stage: build
before_script:
- apk add bash git curl jq make
script:
- make build
- make save
extends: .parallel
only:
- merge_requests
- tags
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
artifacts:
paths:
- "tarballs/"
test:
stage: test
before_script:
- apk add bash git curl jq make
script:
- make load
- make build-test
@@ -43,15 +50,18 @@ test:
- TARGET: oldstable
- TARGET: stable
- TARGET: unstable
only:
- merge_requests
- tags
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
artifacts:
paths:
- tarballs/
publish-images:
stage: release
before_script:
- apk add bash git curl jq make
script:
- make load
- make publish-images
@@ -64,8 +74,9 @@ publish-images:
- TARGET: unstable
- job: test
extends: .parallel
only:
- tags
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
artifacts:
paths:
- tarballs/
@@ -73,8 +84,9 @@ publish-images:
make-documents:
stage: release
before_script:
- apk add bash git curl jq make py3-jinja2
script:
- apk add py3-jinja2
- make documents
needs:
- job: publish-images
@@ -83,8 +95,9 @@ make-documents:
- TARGET: oldstable
- TARGET: stable
- TARGET: unstable
only:
- tags
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
artifacts:
paths:
- versions/*
@@ -92,12 +105,43 @@ make-documents:
publish-documents:
stage: release
before_script:
- apk add bash git curl jq make
script:
- make publish-documents
needs:
- job: make-documents
only:
- tags
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
artifacts:
paths:
- documentations/*.md
- documentations/*.md
weekly-build-disable:
stage: release
needs:
- job: publish-documents
before_script:
- apk add bash git curl jq make py3-requests py3-gitlab
script:
- make unschedule-weekly-build
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
weekly-build-scheduler:
stage: schedule
before_script:
- apk add bash git curl jq make py3-requests py3-gitlab
script:
- make schedule-weekly-build
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build-scheduler"
artifacts:
reports:
metrics: metrics.txt
code_quality:
rules:
- if: $CI_MERGE_REQUEST_ID

View File

@@ -14,9 +14,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
### Fixed
### Security
[tag]: url_to_tag
-->
## [3.0.1]
### Added
* New script to schedule the best possible time to run the build. It relies on WattTime Load Shift feature (#56)
* Weekly build through pipeline schedules. (#56)
### Changed
* Every links pointing to the previous repository flwgns-docker/seafile-client are pointing now to florian.anceau/docker-seafile-client. (#56)
[3.0.1]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/3.0.1
<!-- /3.0.1 -->
## [3.0.0] - 2024/03/16
### Added
- Support for multiple libraries synchronization (#44, #43, #41)
@@ -31,7 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed the Docker Hub description publish through their API (#10)
- Add ca-certificates and gnupg to support more HTTP certificates (#24)
[3.0.0]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/3.0.0
[3.0.0]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/3.0.0
<!-- /3.0.0 -->
## [2.2.0] - 2022/08/26
@@ -101,23 +112,23 @@ The container entrypoint is run with root, then another entrypoint is run by the
## [0.9.2] - 2019/03/15
- Test release on GitLab, before Docker Hub
[2.2.0]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.2.0
[2.1.1]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.1.1
[2.1.0]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.1.0
[2.0.3]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.0.2
[2.0.2]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.0.2
[2.0.1]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.0.1
[2.0.0]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.0.0
[1.2.1]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.2.1
[1.2.0]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.2.0
[1.1.2]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.1.2
[1.1.1]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.1.1
[1.1.0]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.1.0
[1.0.6]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.6
[1.0.5]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.5
[1.0.4]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.4
[1.0.3]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.3
[1.0.2]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.2
[1.0.1]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.1
[1.0.0]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.0
[0.9.2]: https://gitlab.com/flwgns-docker/seafile-client/-/tags/0.9.2
[2.2.0]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/2.2.0
[2.1.1]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/2.1.1
[2.1.0]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/2.1.0
[2.0.3]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/2.0.2
[2.0.2]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/2.0.2
[2.0.1]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/2.0.1
[2.0.0]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/2.0.0
[1.2.1]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.2.1
[1.2.0]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.2.0
[1.1.2]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.1.2
[1.1.1]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.1.1
[1.1.0]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.1.0
[1.0.6]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.0.6
[1.0.5]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.0.5
[1.0.4]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.0.4
[1.0.3]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.0.3
[1.0.2]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.0.2
[1.0.1]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.0.1
[1.0.0]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/1.0.0
[0.9.2]: https://gitlab.com/florian.anceau/docker-seafile-client/-/tags/0.9.2

View File

@@ -13,10 +13,10 @@
They are several ways to help and improve this project.
## Report issues, propose features
You think you found a bug ? You think something is missing out ? Check that it has not been [already reported](https://gitlab.com/flwgns-docker/seafile-client/-/issues). If it has not, [report it](https://gitlab.com/flwgns-docker/seafile-client/-/issues/new?issue).
You think you found a bug ? You think something is missing out ? Check that it has not been [already reported](https://gitlab.com/florian.anceau/docker-seafile-client/-/issues). If it has not, [report it](https://gitlab.com/florian.anceau/docker-seafile-client/-/issues/new?issue).
## Solve problems
You can't wait for a problem to be solved ? Pick one from the [already reported problems](https://gitlab.com/flwgns-docker/seafile-client/-/issues) and solve it. It will be greatly appreciated!
You can't wait for a problem to be solved ? Pick one from the [already reported problems](https://gitlab.com/florian.anceau/docker-seafile-client/-/issues) and solve it. It will be greatly appreciated!
## Say thanks
One great way to help is simply to say thanks. You can do that by [adding a star to the Docker Hub repository](https://hub.docker.com/r/flowgunso/seafile-client) or [just saying thanks in the project topic on Seafile's forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573).

View File

@@ -46,4 +46,10 @@ save:
docker save --output tarballs/${TARGET}.tar seafile-client:${TARGET}
load:
docker load --input tarballs/${TARGET}.tar
docker load --input tarballs/${TARGET}.tar
schedule-weekly-build:
python scripts/schedule-build.py
unschedule-weekly-build:
python scripts/schedule-build.py --disable

View File

@@ -5,9 +5,9 @@
[![][badge-license]][url-sources]
[![][badge-sponsoring]][url-sponsoring]
[url-pipelines]: https://gitlab.com/flwgns-docker/seafile-client/-/pipelines
[url-pipelines]: https://gitlab.com/florian.anceau/docker-seafile-client/-/pipelines
[url-docker]: https://hub.docker.com/r/flowgunso/seafile-client
[url-sources]: https://gitlab.com/flwgns-docker/seafile-client/
[url-sources]: https://gitlab.com/florian.anceau/docker-seafile-client/
[url-sponsoring]: https://liberapay.com/docker-seafile-client/donate
[badge-pipeline]: https://img.shields.io/gitlab/pipeline-status/flwgns-docker%2Fseafile-client
@@ -167,4 +167,4 @@ volumes:
# Troubleshooting
* Ask questions on [Seafile forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573).
* Contribute and report issues on [Gitlab](https://gitlab.com/flwgns-docker/seafile-client/).
* Contribute and report issues on [Gitlab](https://gitlab.com/florian.anceau/docker-seafile-client/).

View File

@@ -2,14 +2,17 @@
[![][badge-image-size]][url-docker]
[![][badge-pulls]][url-docker]
[![][badge-release]][url-sources]
![][badge-license]
[![][badge-license]][url-sources]
[![][badge-sponsoring]][url-sponsoring]
[url-pipelines]: https://gitlab.com/flwgns-docker/seafile-client/-/pipelines
[url-pipelines]: https://gitlab.com/florian.anceau/docker-seafile-client/-/pipelines
[url-docker]: https://hub.docker.com/r/flowgunso/seafile-client
[url-sources]: https://gitlab.com/flwgns-docker/seafile-client/
[url-sources]: https://gitlab.com/florian.anceau/docker-seafile-client/
[url-sponsoring]: https://liberapay.com/docker-seafile-client/donate
[badge-pipeline]: https://img.shields.io/gitlab/pipeline-status/flwgns-docker%2Fseafile-client
[badge-pipeline]: https://img.shields.io/gitlab/pipeline-status/florian.anceau%2Fdocker-seafile-client
[badge-image-size]: https://img.shields.io/docker/image-size/flowgunso/seafile-client/latest?logo=docker&label=Image%20size&color=%230778b8
[badge-pulls]: https://img.shields.io/docker/pulls/flowgunso/seafile-client?logo=docker&label=Pulls&color=%230778b8
[badge-license]: https://img.shields.io/gitlab/license/11322291?label=License&color=fca326
[badge-release]: https://img.shields.io/gitlab/v/release/11322291?logo=gitlab&label=Source%20code&color=fca326
[badge-release]: https://img.shields.io/gitlab/v/release/11322291?logo=gitlab&label=Source%20code&color=fca326
[badge-sponsoring]: https://img.shields.io/liberapay/receives/docker-seafile-client.svg?logo=liberapay

View File

@@ -5,3 +5,5 @@
* Configure upload and download limits.
* Skip SSL certificates.
* Set file ownership with user/group ID
The Docker image is built weekly to keep up with security updates.

View File

@@ -6,4 +6,4 @@ The versions match Seafile versions.
[{{ version | join(", ")}}][Dockerfile]
{% endfor %}
[Dockerfile]: https://gitlab.com/flwgns-docker/seafile-client/-/blob/master/seafile-client/Dockerfile
[Dockerfile]: https://gitlab.com/florian.anceau/docker-seafile-client/-/blob/master/seafile-client/Dockerfile

View File

@@ -1,3 +1,3 @@
# Troubleshooting
* Ask questions on [Seafile forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573).
* Contribute and report issues on [Gitlab](https://gitlab.com/flwgns-docker/seafile-client/).
* Contribute and report issues on [Gitlab](https://gitlab.com/florian.anceau/docker-seafile-client/).

View File

@@ -12,7 +12,7 @@ Feedback is welcome so I can keep improving it.
# Quick informations
**[flowgunso/seafile-client](https://hub.docker.com/r/flowgunso/seafile-client)** on Docker Hub, latest stable version: **{{version}}**
Contribute and report issues on [Gitlab](https://gitlab.com/flwgns-docker/seafile-client/).
Contribute and report issues on [Gitlab](https://gitlab.com/florian.anceau/docker-seafile-client/).
{% include "parts/supported_tags.md.j2" %}

132
scripts/schedule-build.py Normal file
View File

@@ -0,0 +1,132 @@
# !/usr/bin/env python
import os
import argparse
import sys
from datetime import datetime
import requests
from requests.auth import HTTPBasicAuth
from gitlab import Gitlab
class Scheduler:
WATTTIME_SIGNAL_TYPE="co2_moer"
def __init__(self, watttime_username, watttime_password, gitlab_private_token,
gitlab_project_id, gitlab_scheduled_pipeline_id):
# Instanciate the WattTime session.
url = "https://api.watttime.org/login"
response = requests.get(url, auth=HTTPBasicAuth(watttime_username, watttime_password))
payload = response.json()
token = payload["token"]
headers = {"Authorization": f"Bearer {token}"}
self.watttime = requests.session()
self.watttime.headers = headers
# Instanciate the Gitlab session and grab the Weekly build scheduled pipeline.
self.gitlab = Gitlab(private_token=gitlab_private_token)
project = self.gitlab.projects.get(gitlab_project_id)
self.pipeline = project.pipelineschedules.get(gitlab_scheduled_pipeline_id)
def geolocate(self):
url = "https://ipinfo.io"
response = requests.get(url)
payload = response.json()
geolocation = payload["loc"]
self.latitude, self.longitude = geolocation.split(",")
def load_shift(self):
# Get region from geolocation.
# TODO: uncomment once premium plan
# url = "https://api.watttime.org/v3/region-from-loc"
# params = {
# "latitude": self.latitude,
# "longitude": self.longitude,
# "signal_type": self.WATTTIME_SIGNAL_TYPE}
# response = self.watttime.get(url, params=params)
# payload = response.json()
# region = payload["region"]
# Get the forecast for said region.
# TODO: don't override the region, get a premium plan
url = "https://api.watttime.org/v3/forecast"
region = "CAISO_NORTH" # Override the region until I get a premium plan
params = {"region": region, "signal_type": self.WATTTIME_SIGNAL_TYPE}
response = self.watttime.get(url, params=params)
payload = response.json()
data = payload["data"]
# Look for the lowest value and it's datetime. Store the current value to know improvements.
lowest_value: float = None
for obj in data:
value = obj["value"]
point_time = datetime.fromisoformat(obj["point_time"])
if not lowest_value:
self.now_value = self.lowest_value = value
self.now = self.then = point_time
continue
if value < lowest_value:
lowest_value = value
self.then = point_time
def metrics(self):
# Write WattTime metrics.
metrics = {}
metrics["watttime_now"] = self.now_value
metrics["watttime_lowest"] = self.lowest_value
metrics["now"] = self.now
metrics["self.then"] = self.then
with open("metrics.txt", "wt") as fileobject:
for metric, value in metrics.items():
fileobject.write(f"{metric} {value}\n")
# TODO: track the metrics of energy cost/gain
def schedule(self):
# Test ownership prior to overtaking ownership.
self.gitlab.auth()
if self.pipeline.owner["id"] != self.gitlab.user.id:
self.pipeline.take_ownership()
# Set pipeline cron schedule to WattTime's Load Shift best moment.
cron = f"{self.then.minute} {self.then.hour} {self.then.day} {self.then.month} *"
self.pipeline.cron = cron
self.pipeline.active = True
self.pipeline.save()
def unschedule(self):
self.pipeline.active = False
self.pipeline.save()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="",
description="",
epilog=""
)
parser.add_argument("--disable", action="store_true")
args = parser.parse_args()
disable = args.disable
scheduler = Scheduler(
watttime_username=os.environ["WATTTIME_USERNAME"],
watttime_password=os.environ["WATTTIME_PASSWORD"],
gitlab_project_id=os.environ["CI_PROJECT_ID"],
gitlab_private_token=os.environ["WEEKLY_BUILD_PRIVATE_TOKEN"],
gitlab_scheduled_pipeline_id=os.environ["WEEKLY_BUILD_PIPELINE_ID"]
)
if disable:
scheduler.unschedule()
sys.exit()
scheduler.geolocate()
scheduler.load_shift()
scheduler.metrics()
scheduler.schedule()

View File

@@ -41,8 +41,8 @@ ARG VERSION
LABEL org.opencontainers.image.created=${CREATED}
LABEL org.opencontainers.image.authors="flow.gunso@gmail.com"
LABEL org.opencontainers.image.url="https://hub.docker.com/r/flowgunso/seafile-client"
LABEL org.opencontainers.image.documentation="https://gitlab.com/flwgns-docker/seafile-client"
LABEL org.opencontainers.image.source="https://gitlab.com/flwgns-docker/seafile-client"
LABEL org.opencontainers.image.documentation="https://gitlab.com/florian.anceau/docker-seafile-client"
LABEL org.opencontainers.image.source="https://gitlab.com/florian.anceau/docker-seafile-client"
LABEL org.opencontainers.image.version=${VERSION}
LABEL org.opencontainers.image.revision=${REVISION}
LABEL org.opencontainers.image.licenses="GPL-3.0"