Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 7a6b8d14 authored by ANDRADE-BARROSO Guillermo's avatar ANDRADE-BARROSO Guillermo
Browse files

Merge branch 'ci' into 'master'

Ci

See merge request !11
parents 41e90a35 73a4a18e
Branches
Tags
1 merge request!11Ci
Pipeline #93273 passed
...@@ -3,7 +3,19 @@ ...@@ -3,7 +3,19 @@
# https://hub.docker.com/r/library/python/tags/ # https://hub.docker.com/r/library/python/tags/
image: python:3.6 image: python:3.6
#### Entering th release zone variables:
PYTHONUNBUFFERED: 1
functionnal:
stage: test
script:
- pip install .
# Alternative keyring (plain text/for testing purpose only)
- pip install keyrings.alt
- keyring --list-backends
- python sharelatex/tests/functionnal.py
#### Entering the release zone
pages: pages:
stage: deploy stage: deploy
tags: [qlf-ci.inria.fr] tags: [qlf-ci.inria.fr]
......
...@@ -571,3 +571,30 @@ class SyncClient: ...@@ -571,3 +571,30 @@ class SyncClient:
r.raise_for_status() r.raise_for_status()
response = r.json() response = r.json()
return response return response
def new(self, project_name):
"""Create a new example project for the current user.
Args:
project_name (str): The project name of the project to create
"""
url = f"{self.base_url}/project/new"
data = {"_csrf": self.csrf, "projectName": project_name, "template": "example"}
r = self._post(url, data=data, verify=self.verify)
r.raise_for_status()
response = r.json()
return response
def delete(self, project_id, *, forever=False):
"""Delete a project for the current user.
Args:
project_id (str): The project id of the project to delete
"""
url = f"{self.base_url}/project/{project_id}"
data = {"_csrf": self.csrf}
params = {"forever": forever}
r = self._delete(url, data=data, params=params, verify=self.verify)
r.raise_for_status()
return r
from contextlib import contextmanager
import os
from sharelatex import SyncClient
from subprocess import check_call
import tempfile
BASE_URL = os.environ.get("CI_BASE_URL")
USERNAME = os.environ.get("CI_USERNAME")
PASSWORD = os.environ.get("CI_PASSWORD")
def log(f):
def wrapped(*args, **kwargs):
print("-"*60)
print("{:^60}".format(f.__name__.upper()))
print("-"*60)
return f(*args, **kwargs)
return wrapped
@contextmanager
def project(project_name):
client = SyncClient(base_url=BASE_URL, username=USERNAME, password=PASSWORD)
with tempfile.TemporaryDirectory() as temp_path:
os.chdir(temp_path)
r = client.new(project_name)
project_id = r["project_id"]
path = os.path.join(temp_path, project_id)
# TODO(msimonin) yield the repo object also
yield (client, path, project_id)
client.delete(project_id, forever=True)
@log
def clone():
with project("clone") as (_, _, project_id):
url = f"{BASE_URL}/project/{project_id}"
check_call(
f"git slatex clone {url} --username={USERNAME} --password={PASSWORD} --save-password",
shell=True,
)
@log
def clone_and_pull():
with project("clone_and_pull") as (_, path, project_id):
url = f"{BASE_URL}/project/{project_id}"
check_call(
f"git slatex clone {url} --username={USERNAME} --password={PASSWORD} --save-password",
shell=True,
)
os.chdir(path)
check_call("git slatex pull", shell=True)
if __name__ == "__main__":
clone()
clone_and_pull()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment