Repository: certbot/certbot

Issue:
Switch to GitHub Actions or Azure Pipelines
We basically need this for https://github.com/certbot/certbot/issues/8041 to make it sane to create a Certbot snap that can be easily shared and used for testing the DNS plugin snaps as described at https://github.com/certbot/certbot/issues/8041#issuecomment-642849813.


Discussion:

Resolving patch:
diff --git a/acme/setup.py b/acme/setup.py
--- a/acme/setup.py
+++ b/acme/setup.py
@@ -17,8 +17,8 @@
     # 1.1.0+ is required to avoid the warnings described at
     # https://github.com/certbot/josepy/issues/13.
     'josepy>=1.1.0',
-    # Connection.set_tlsext_host_name (>=0.13)
-    'PyOpenSSL>=0.13.1',
+    # Connection.set_tlsext_host_name (>=0.13) + matching Xenial requirements (>=0.15.1)
+    'PyOpenSSL>=0.15.1',
     'pyrfc3339',
     'pytz',
     'requests[security]>=2.6.0',  # security extras added in 2.4.1


Test patch:
diff --git a/tests/letstest/multitester.py b/tests/letstest/multitester.py
--- a/tests/letstest/multitester.py
+++ b/tests/letstest/multitester.py
@@ -63,10 +63,6 @@
 parser.add_argument('test_script',
                     default='test_letsencrypt_auto_certonly_standalone.sh',
                     help='path of bash script in to deploy and run')
-#parser.add_argument('--script_args',
-#                    nargs='+',
-#                    help='space-delimited list of arguments to pass to the bash test script',
-#                    required=False)
 parser.add_argument('--repo',
                     default='https://github.com/letsencrypt/letsencrypt.git',
                     help='certbot git repo to use')
@@ -238,20 +234,20 @@ def block_until_instance_ready(booting_instance, wait_time=5, extra_wait_time=20
 # Fabric Routines
 #-------------------------------------------------------------------------------
 def local_git_clone(local_cxn, repo_url):
-    "clones master of repo_url"
+    """clones master of repo_url"""
     local_cxn.local('cd %s && if [ -d letsencrypt ]; then rm -rf letsencrypt; fi' % LOGDIR)
     local_cxn.local('cd %s && git clone %s letsencrypt'% (LOGDIR, repo_url))
     local_cxn.local('cd %s && tar czf le.tar.gz letsencrypt'% LOGDIR)
 
 def local_git_branch(local_cxn, repo_url, branch_name):
-    "clones branch <branch_name> of repo_url"
+    """clones branch <branch_name> of repo_url"""
     local_cxn.local('cd %s && if [ -d letsencrypt ]; then rm -rf letsencrypt; fi' % LOGDIR)
     local_cxn.local('cd %s && git clone %s letsencrypt --branch %s --single-branch'%
         (LOGDIR, repo_url, branch_name))
     local_cxn.local('cd %s && tar czf le.tar.gz letsencrypt' % LOGDIR)
 
 def local_git_PR(local_cxn, repo_url, PRnumstr, merge_master=True):
-    "clones specified pull request from repo_url and optionally merges into master"
+    """clones specified pull request from repo_url and optionally merges into master"""
     local_cxn.local('cd %s && if [ -d letsencrypt ]; then rm -rf letsencrypt; fi' % LOGDIR)
     local_cxn.local('cd %s && git clone %s letsencrypt' % (LOGDIR, repo_url))
     local_cxn.local('cd %s && cd letsencrypt && '
@@ -264,20 +260,20 @@ def local_git_PR(local_cxn, repo_url, PRnumstr, merge_master=True):
     local_cxn.local('cd %s && tar czf le.tar.gz letsencrypt' % LOGDIR)
 
 def local_repo_to_remote(cxn):
-    "copies local tarball of repo to remote"
+    """copies local tarball of repo to remote"""
     filename = 'le.tar.gz'
     local_path = os.path.join(LOGDIR, filename)
     cxn.put(local=local_path, remote='')
     cxn.run('tar xzf %s' % filename)
 
 def local_repo_clean(local_cxn):
-    "delete tarball"
+    """delete tarball"""
     filename = 'le.tar.gz'
     local_path = os.path.join(LOGDIR, filename)
     local_cxn.local('rm %s' % local_path)
 
 def deploy_script(cxn, scriptpath, *args):
-    "copies to remote and executes local script"
+    """copies to remote and executes local script"""
     cxn.put(local=scriptpath, remote='', preserve_mode=True)
     scriptfile = os.path.split(scriptpath)[1]
     args_str = ' '.join(args)
@@ -425,23 +421,23 @@ def main():
     print("Making local dir for test repo and logs: %s"%LOGDIR)
     local_cxn.local('mkdir %s'%LOGDIR)
 
-    # figure out what git object to test and locally create it in LOGDIR
-    print("Making local git repo")
     try:
+        # figure out what git object to test and locally create it in LOGDIR
+        print("Making local git repo")
         if cl_args.pull_request != '~':
-            print('Testing PR %s '%cl_args.pull_request,
+            print('Testing PR %s ' % cl_args.pull_request,
                   "MERGING into master" if cl_args.merge_master else "")
             local_git_PR(local_cxn, cl_args.repo, cl_args.pull_request, cl_args.merge_master)
         elif cl_args.branch != '~':
-            print('Testing branch %s of %s'%(cl_args.branch, cl_args.repo))
+            print('Testing branch %s of %s' % (cl_args.branch, cl_args.repo))
             local_git_branch(local_cxn, cl_args.repo, cl_args.branch)
         else:
-            print('Testing master of %s'%cl_args.repo)
+            print('Testing current branch of %s' % cl_args.repo)
             local_git_clone(local_cxn, cl_args.repo)
     except BaseException:
         print("FAIL: trouble with git repo")
         traceback.print_exc()
-        exit()
+        exit(1)
 
 
     # Set up EC2 instances
diff --git a/tests/letstest/travis-setup.sh b/tests/letstest/travis-setup.sh
deleted file mode 100755
--- a/tests/letstest/travis-setup.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash -ex
-#
-# Preps the test farm tests to be run in Travis.
-
-if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
-    echo This script must be run in Travis on a non-pull request build
-    exit 1
-fi
-
-openssl aes-256-cbc -K "${encrypted_9a387195a62e_key}" -iv "${encrypted_9a387195a62e_iv}" -in travis-test-farm.pem.enc -out travis-test-farm.pem -d
diff --git a/tests/letstest/travis-test-farm.pem.enc b/tests/letstest/travis-test-farm.pem.enc
deleted file mode 100644
Binary files a/tests/letstest/travis-test-farm.pem.enc and /dev/null differ
diff --git a/tests/lock_test.py b/tests/lock_test.py
--- a/tests/lock_test.py
+++ b/tests/lock_test.py
@@ -59,9 +59,9 @@ def set_up():
     command = set_up_command(config_dir, logs_dir, work_dir, nginx_dir)
 
     dirs = [logs_dir, config_dir, work_dir]
-    # Travis and Circle CI set CI to true so we
-    # will always test Nginx's lock during CI
-    if os.environ.get('CI') == 'true' or util.exe_exists('nginx'):
+    # If Nginx is installed, do the test, otherwise skip it.
+    # Issue https://github.com/certbot/certbot/issues/8121 tracks the work to remove this control.
+    if util.exe_exists('nginx'):
         dirs.append(nginx_dir)
     else:
         logger.warning('Skipping Nginx lock tests')
diff --git a/tests/modification-check.py b/tests/modification-check.py
--- a/tests/modification-check.py
+++ b/tests/modification-check.py
@@ -57,7 +57,7 @@ def validate_scripts_content(repo_path, temp_cwd):
             'letsencrypt-auto-source/pieces/fetch.py')), temp_cwd)
 
         # Compare file against current version in the target branch
-        branch = os.environ.get('TRAVIS_BRANCH', 'master')
+        branch = os.environ.get('TARGET_BRANCH', 'master')
         url = (
             'https://raw.githubusercontent.com/certbot/certbot/{0}/certbot-auto'
             .format(branch))
diff --git a/tools/run_oldest_tests.sh b/tools/run_oldest_tests.sh
new file mode 100755
--- /dev/null
+++ b/tools/run_oldest_tests.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+set -e
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+pushd "${DIR}/../"
+
+function cleanup() {
+  rm -f "${DOCKERFILE}"
+  popd
+}
+
+trap cleanup EXIT
+
+DOCKERFILE=$(mktemp /tmp/Dockerfile.XXXXXX)
+
+cat << "EOF" >> "${DOCKERFILE}"
+FROM ubuntu:16.04
+COPY pipstrap.py /tmp/pipstrap.py
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+        python-dev python-pip python-setuptools \
+        gcc libaugeas0 libssl-dev libffi-dev \
+        git ca-certificates nginx-light openssl curl \
+ && curl -fsSL https://get.docker.com | bash /dev/stdin \
+ && python /tmp/pipstrap.py \
+ && python -m pip install tox \
+ && rm -rf /var/lib/apt/lists/*
+EOF
+
+docker build -f "${DOCKERFILE}" -t oldest-worker ./letsencrypt-auto-source/pieces
+docker run --rm --network=host -w "${PWD}" \
+  -v /var/run/docker.sock:/var/run/docker.sock \
+  -v "${PWD}:${PWD}" -v /tmp:/tmp \
+  -e TOXENV -e ACME_SERVER -e PYTEST_ADDOPTS \
+  oldest-worker python -m tox