Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test against all built #6927

Merged
merged 5 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,38 @@ parameters:
OSName: 'Linux'
OSVmImage: 'ubuntu-16.04'
JavaVersion: '1.8'
RunTitle: 'Linux on Java 1.8'
macOS - Java 8:
OSName: 'macOS'
OSVmImage: 'macOS-10.13'
JavaVersion: '1.8'
RunTitle: 'macOS on Java 1.8'
Windows - Java 8:
OSName: 'Windows'
OSVmImage: 'windows-2019'
JavaVersion: '1.8'
RunTitle: 'Windows on Java 1.8'
Linux - Java 11:
OSName: 'Linux'
OSVmImage: 'ubuntu-16.04'
JavaVersion: '1.11'
RunTitle: 'Linux on Java 1.11'
macOS - Java 11:
OSName: 'macOS'
OSVmImage: 'macOS-10.13'
JavaVersion: '1.11'
RunTitle: 'macOS on Java 1.11'
Windows - Java 11:
OSName: 'Windows'
OSVmImage: 'windows-2019'
JavaVersion: '1.11'
RunTitle: 'Windows on Java 1.11'
Windows From Source - Java 8:
OSName: 'Windows'
OSVmImage: 'windows-2019'
JavaVersion: '1.8'
RunTitle: 'From Source: Windows on Java 1.8'
TestFromSource: true

jobs:
- job: 'Build'
Expand Down Expand Up @@ -277,6 +289,36 @@ jobs:

- ${{ parameters.PreTestSteps }}

# JRSSTART
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you planned to remove this JRSSTART comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed with 5th commit.

- task: UsePythonVersion@0
displayName: 'Use Python 3.6'
inputs:
versionSpec: '3.6'
condition: and(ne(variables['SdkType'], 'data'), eq(variables['TestFromSource'],'true'))

- pwsh: |
python --version
python eng/versioning/set_versions.py --build-type client --pst
if ($LastExitCode -eq 5678) {
echo "##vso[task.setvariable variable=ShouldRunSourceTests]$true"
echo "Changes detected, return code from set_versions.py is $($LastExitCode)"
exit 0
} elseif ($LastExitCode -eq 0) {
echo "No changes detected, return code from set_versions.py is $($LastExitCode)"
exit 0
} else {
echo "Invalid return code from set_versions.py, return code is $($LastExitCode)"
exit 1
}
displayName: 'Setup for source build'
condition: and(ne(variables['SdkType'], 'data'), eq(variables['TestFromSource'],'true'))

- script: |
python --version
python eng/versioning/update_versions.py --update-type library --build-type client
condition: eq(variables['ShouldRunSourceTests'],'true')
displayName: 'Setup for source build'

- task: Maven@3
displayName: 'Run tests'
inputs:
Expand All @@ -288,9 +330,12 @@ jobs:
jdkArchitectureOption: 'x64'
publishJUnitResults: false
goals: ${{ parameters.TestGoals }}
# we want to run this when TestFromSource isn't true (which covers normal running when it isn't set)
# OR when ShouldRunSourceTests is true
condition: or(ne(variables['TestFromSource'],'true'), eq(variables['ShouldRunSourceTests'],'true'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are going to want to and this condition with "succeeded" https://docs.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#succeeded so that we don't end up trying to run this step when some other step already failed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Updated with latest commit.


- task: PublishTestResults@2
condition: always()
condition: and(always(), or(ne(variables['TestFromSource'],'true'), eq(variables['ShouldRunSourceTests'],'true')))
inputs:
mergeTestResults: true
testRunTitle: '$(OSName) on Java $(JavaVersion)'
testRunTitle: $(RunTitle)
42 changes: 39 additions & 3 deletions eng/versioning/set_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from datetime import timedelta
import os
import re
import sys
import time
from utils import BuildType
from utils import CodeModule
Expand All @@ -37,7 +38,7 @@ def update_versions_file(update_type, build_type, build_qualifier, artifact_id):
print('version_file=' + version_file)

newlines = []
with open(version_file) as f:
with open(version_file, encoding='utf-8') as f:
for raw_line in f:
stripped_line = raw_line.strip()
if not stripped_line or stripped_line.startswith('#'):
Expand All @@ -63,24 +64,59 @@ def update_versions_file(update_type, build_type, build_qualifier, artifact_id):
raise ValueError('{}\'s dependency version + build qualifier {} is not a valid semver version'.format(module.name, module.dependency + build_qualifier))
newlines.append(module.string_for_version_file())

with open(version_file, 'w') as f:
with open(version_file, 'w', encoding='utf-8') as f:
for line in newlines:
f.write(line)

# Prep the appropriate version file for source
def prep_version_file_for_source_testing(build_type):

version_file = os.path.normpath('eng/versioning/version_' + build_type.name + '.txt')
print('version_file=' + version_file)
file_changed = False

newlines = []
with open(version_file, encoding='utf-8') as f:
for raw_line in f:
stripped_line = raw_line.strip()
if not stripped_line or stripped_line.startswith('#'):
newlines.append(raw_line)
else:
module = CodeModule(stripped_line)
if not module.current == module.dependency:
module.dependency = module.current
file_changed = True
newlines.append(module.string_for_version_file())

with open(version_file, 'w', encoding='utf-8') as f:
for line in newlines:
f.write(line)

return file_changed

def main():
parser = argparse.ArgumentParser(description='set version numbers in the appropriate version text file')
parser.add_argument('--update-type', '--ut', type=UpdateType, choices=list(UpdateType))
parser.add_argument('--build-type', '--bt', type=BuildType, choices=list(BuildType))
parser.add_argument('--build-qualifier', '--bq', help='build qualifier to append onto the version string.')
parser.add_argument('--artifact-id', '--ar', help='artifactId to target.')
parser.add_argument('--prep-source-testing', '--pst', action='store_true', help='prep the version file for source testing')
args = parser.parse_args()
if (args.build_type == BuildType.management):
raise ValueError('{} is not currently supported.'.format(BuildType.management.name))
start_time = time.time()
update_versions_file(args.update_type, args.build_type, args.build_qualifier, args.artifact_id)
file_changed = False
if (args.prep_source_testing):
file_changed = prep_version_file_for_source_testing(args.build_type)
else:
update_versions_file(args.update_type, args.build_type, args.build_qualifier, args.artifact_id)
elapsed_time = time.time() - start_time
print('elapsed_time={}'.format(elapsed_time))
print('Total time for replacement: {}'.format(str(timedelta(seconds=elapsed_time))))
# if the file changed flag is set, which only happens through a call to prep_version_file_for_source_testing,
# then exit with a unique code that allows us to know that something changed.
if (file_changed):
sys.exit(5678)

if __name__ == '__main__':
main()