From 761152babe23af6db20297b98c89f2398c750f1b Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Tue, 11 Feb 2020 15:57:11 +0000 Subject: [PATCH] appveyor: first version --- .appveyor.yml | 112 +++++++++++++++++++++++++++ appveyor-test.py | 66 ++++++++++++++++ appveyor/.appveyor.yml.example-full | 113 ++++++++++++++++++++++++++++ appveyor/do.py | 104 +++++++++++++++++++++++++ 4 files changed, 395 insertions(+) create mode 100644 .appveyor.yml create mode 100644 appveyor-test.py create mode 100644 appveyor/.appveyor.yml.example-full create mode 100644 appveyor/do.py diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..b336a73 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,112 @@ +# .appveyor.yml for testing EPICS Base ci-scripts +# (see: https://github.com/epics-base/ci-scripts) + +# Note: +# Paths to scripts are different in this test configuration +# (your module has one more directory level: .ci) + +# Ralph Lange +# Copyright (c) 2020 ITER Organization + + +#---------------------------------# +# repository cloning # +#---------------------------------# + +# Called at very beginning, before repo cloning +init: + # Set autocrlf to make batch files work + - git config --global core.autocrlf true + +# Set clone depth (do not fetch complete history) +clone_depth: 50 + +# Skipping commits affecting only specific files +skip_commits: + files: + - 'documentation/*' + - 'templates/*' + - '**/*.html' + - '**/*.md' + +#---------------------------------# +# build matrix configuration # +#---------------------------------# + +# Build Configurations: dll/static, regular/debug +configuration: + - dynamic + - static + - dynamic-debug + - static-debug + +# Environment variables: compiler toolchain +environment: + matrix: + - CC: mingw + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + - CC: vs2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + - CC: vs2017 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + - CC: vs2015 + - CC: vs2013 + - CC: vs2012 + - CC: vs2010 + +# Platform: architecture +platform: +# - x86 + - x64 + +# Matrix configuration: allow specific failing jobs +matrix: + exclude: + # VS2010 Express installs don't have the 64 bit compiler + - platform: x64 + CC: vs2010 + # Exclude to reduce total job runtime + # skip 64-bit for older and 32-bit for newer + - platform: x64 + CC: vs2012 + - platform: x86 + CC: mingw + - platform: x86 + CC: vs2019 + - platform: x86 + CC: vs2017 + + +#---------------------------------# +# building & testing # +#---------------------------------# + +build_script: + - cmd: python appveyor-test.py + + +#---------------------------------# +# debugging # +#---------------------------------# + +## if you want to connect by remote desktop to a failed build, uncomment these lines +## note that you will need to connect within the usual build timeout limit (60 minutes) +## so you may want to adjust the build matrix above to just build the one of interest + +#on_failure: +# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + + +#---------------------------------# +# notifications # +#---------------------------------# + +notifications: + +# - provider: Email +# to: +# - core-talk@aps.anl.gov +# on_build_success: false + +# - provider: GitHubPullRequest diff --git a/appveyor-test.py b/appveyor-test.py new file mode 100644 index 0000000..7828a5f --- /dev/null +++ b/appveyor-test.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +"""Module ci-scripts AppVeyor unit tests +""" + +# SET=test00 in .appveyor.yml runs the tests in this script +# all other jobs are started as compile jobs + +import sys, os +import unittest + +sys.path.append('appveyor') +import do + +class TestSourceSet(unittest.TestCase): + + def setUp(self): + os.environ['SETUP_PATH'] = '.:appveyor' + if 'BASE' in os.environ: + del os.environ['BASE'] + do.clear_lists() + + def test_EmptySetupDirsPath(self): + del os.environ['SETUP_PATH'] + try: + do.source_set('test01') + except NameError: + return + self.fail('source_set did not throw on empty SETUP_DIRS') + + def test_InvalidSetupName(self): + try: + do.source_set('xxdoesnotexistxx') + except NameError: + return + self.fail('source_set did not throw on invalid file name') + + def test_ValidSetupName(self): + do.source_set('test01') + self.assertEqual(do.setup['BASE'], '7.0', 'BASE was not set to \'7.0\'') + + def test_SetupDoesNotOverridePreset(self): + os.environ['BASE'] = 'foo' + do.source_set('test01') + self.assertEqual(do.setup['BASE'], 'foo', + 'Preset BASE was overridden by test01 setup (expected \'foo\' got {0})' + .format(do.setup['BASE'])) + + def test_IncludeSetupFirstSetWins(self): + do.source_set('test02') + self.assertEqual(do.setup['BASE'], 'foo', + 'BASE set in test02 was overridden by test01 setup (expected \'foo\' got {0})' + .format(do.setup['BASE'])) + self.assertEqual(do.setup['FOO'], 'bar', 'Setting of single word does not work') + self.assertEqual(do.setup['FOO2'], 'bar bar2', 'Setting of multiple words does not work') + self.assertEqual(do.setup['FOO3'], 'bar bar2', 'Indented setting of multiple words does not work') + self.assertEqual(do.setup['SNCSEQ'], 'R2-2-7', 'Setup test01 was not included') + + + + + + +if __name__ == "__main__": + suite = unittest.TestLoader().loadTestsFromTestCase(TestSourceSet) + unittest.TextTestRunner(verbosity=2).run(suite) +# unittest.main() diff --git a/appveyor/.appveyor.yml.example-full b/appveyor/.appveyor.yml.example-full new file mode 100644 index 0000000..662edd2 --- /dev/null +++ b/appveyor/.appveyor.yml.example-full @@ -0,0 +1,113 @@ +# .appveyor.yml for use with EPICS Base ci-scripts +# (see: https://github.com/epics-base/ci-scripts) + +# This is YAML - indentation levels are crucial + +#---------------------------------# +# repository cloning # +#---------------------------------# + +# Called at very beginning, before repo cloning +init: + # Set autocrlf to make batch files work + - git config --global core.autocrlf true + +# Set clone depth (do not fetch complete history) +clone_depth: 50 + +# Skipping commits affecting only specific files +skip_commits: + files: + - 'documentation/*' + - 'templates/*' + - '**/*.html' + - '**/*.md' + +#---------------------------------# +# build matrix configuration # +#---------------------------------# + +# Build Configurations: dll/static, regular/debug +configuration: + - dynamic + - static + - dynamic-debug + - static-debug + +# Environment variables: compiler toolchain +environment: + matrix: + - CC: mingw + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + - CC: vs2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + - CC: vs2017 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + - CC: vs2015 + - CC: vs2013 + - CC: vs2012 + - CC: vs2010 + +# Platform: architecture +platform: + - x86 + - x64 + +# Matrix configuration: allow specific failing jobs +matrix: + exclude: + # VS2010 Express installs don't have the 64 bit compiler + - platform: x64 + CC: vs2010 + # Exclude to reduce total job runtime + # skip 64-bit for older and 32-bit for newer + - platform: x64 + CC: vs2012 + - platform: x86 + CC: mingw + - platform: x86 + CC: vs2019 + - platform: x86 + CC: vs2017 + +#---------------------------------# +# building & testing # +#---------------------------------# + +install: + - cmd: git submodule update --init --recursive + - cmd: python .ci/appveyor/do.py prepare + +build_script: + - cmd: python .ci/appveyor/do.py build + +test_script: + - cmd: python .ci/appveyor/do.py test + +on_finish: + - ps: Get-ChildItem *.tap -Recurse -Force | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } + +#---------------------------------# +# debugging # +#---------------------------------# + +## if you want to connect by remote desktop to a failed build, uncomment these lines +## note that you will need to connect within the usual build timeout limit (60 minutes) +## so you may want to adjust the build matrix above to just build the one of interest + +#on_failure: +# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + +#---------------------------------# +# notifications # +#---------------------------------# + +notifications: + + - provider: Email + to: + - me@example.com + on_build_success: false + + - provider: GitHubPullRequest diff --git a/appveyor/do.py b/appveyor/do.py new file mode 100644 index 0000000..b07a21b --- /dev/null +++ b/appveyor/do.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +"""Windows (AppVeyor) ci build script +""" + +import sys, os +import logging +import subprocess as SP +import distutils.util +from glob import glob + +#logging.basicConfig(level=logging.DEBUG) + +# Setup ANSI Colors +ANSI_RED = "\033[31;1m" +ANSI_GREEN = "\033[32;1m" +ANSI_YELLOW = "\033[33;1m" +ANSI_BLUE = "\033[34;1m" +ANSI_RESET = "\033[0m" +ANSI_CLEAR = "\033[0K" + +seen_setups = [] +setup = {} + +# Used from unittests +def clear_lists(): + del seen_setups[:] + setup.clear() + +# source_set(setup) +# +# Source a settings file (extension .set) found in the setup_dirs path +# May be called recursively (from within a setup file) +def source_set(args): + found = False + + setup_dirs = os.getenv('SETUP_PATH', "").replace(':', ' ').split() + if len(setup_dirs) == 0: + raise NameError("{0}Search path for setup files (SETUP_PATH) is empty{1}".format(ANSI_RED,ANSI_RESET)) + + for set_dir in setup_dirs: + set_file = os.path.join(set_dir, args) + ".set" + + if set_file in seen_setups: + print("Ignoring already included setup file {0}".format(set_file)) + return + + if os.path.isfile(set_file): + seen_setups.append(set_file) + print("Loading setup file {0}".format(set_file)) + with open(set_file) as fp: + for line in fp: + logging.debug('Next line: {0}'.format(line.strip())) + if not line.strip() or line.strip()[0] == '#': + continue + if line.startswith("include"): + logging.debug('Found an include, reading {0}'.format(line.split()[1])) + source_set(line.split()[1]) + continue + assign = line.replace('"', '').strip().split("=", 1) + logging.debug('Interpreting as assignment') + if assign[0] not in setup: + setup[assign[0]] = os.getenv(assign[0], "") + if not setup[assign[0]].strip(): + logging.debug('Doing assignment: {0} = {1}'.format(assign[0], assign[1])) + setup[assign[0]] = assign[1] + found = True + break + + if not found: + raise NameError("{0}Setup file {1} does not exist in SETUP_PATH search path ({2}){3}" + .format(ANSI_RED,set_file,setup_dirs,ANSI_RESET)) + +def prepare(args): + print(sys.version) + print('PYTHONPATH') + for dname in sys.path: + print(' ', dname) + print('platform = ', distutils.util.get_platform()) + + print('{0}Loading setup files{1}'.format(ANSI_YELLOW, ANSI_RESET)) + source_set(default) + if 'SET' in os.environ: + source_set(os.environ['SET']) + + print('Installing dependencies') + +def build(args): + print('Building the module') + +def test(args): + print('Running the tests') + +actions = { + 'prepare': prepare, + 'build': build, + 'test': test, +} + +if __name__=='__main__': + args = sys.argv[1:] + while len(args)>0: + name = args.pop(0) + print('IN', name, 'with', args) + actions[name](args)