* 🐛 Make integration tests compatible w/ modern Git This patch makes use of the `init.defaultBranch` setting to unify the test across new and old Git versions since one defaults to `master` and the other uses `main` for the default branch. Where possible, it uses the `HEAD` committish to avoid having to normalize the branch name. The change fixes the following integration tests: * `ansible-galaxy` * `ansible-galaxy-collection-scm` (recursive collection) * `git` * 🐛Replace `git-symbolic-ref` with a repo template This custom Git repository template emulates the `init.defaultBranch` setting on Git versions below 2.28. Ref: https://superuser.com/a/1559582. Other workarounds mentioned there, like invoking `git symbolic-ref HEAD refs/heads/main` after each `git init` turned out to have mysterious side effects that break the tests in surprising ways. * 🎨 Make Git integration test non-destructive This patch makes use of the `$HOME` environment variable to trick Git into using a user-global config generated in the temporary directory.
63 lines
1.8 KiB
YAML
63 lines
1.8 KiB
YAML
- name: MISSING-HOSTKEY | checkout ssh://git@github.com repo without accept_hostkey (expected fail)
|
|
git:
|
|
repo: '{{ repo_format2 }}'
|
|
dest: '{{ checkout_dir }}'
|
|
ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
|
|
register: git_result
|
|
ignore_errors: true
|
|
|
|
- assert:
|
|
that:
|
|
- git_result is failed
|
|
|
|
- name: MISSING-HOSTKEY | checkout git@github.com repo with accept_hostkey (expected pass)
|
|
git:
|
|
repo: '{{ repo_format2 }}'
|
|
dest: '{{ checkout_dir }}'
|
|
accept_hostkey: true
|
|
key_file: '{{ github_ssh_private_key }}'
|
|
ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
|
|
register: git_result
|
|
when: github_ssh_private_key is defined
|
|
|
|
- assert:
|
|
that:
|
|
- git_result is changed
|
|
when: github_ssh_private_key is defined
|
|
|
|
- name: MISSING-HOSTKEY | clear checkout_dir
|
|
file:
|
|
state: absent
|
|
path: '{{ checkout_dir }}'
|
|
when: github_ssh_private_key is defined
|
|
|
|
- name: MISSING-HOSTKEY | checkout ssh://git@github.com repo with accept_hostkey (expected pass)
|
|
git:
|
|
repo: '{{ repo_format3 }}'
|
|
dest: '{{ checkout_dir }}'
|
|
version: >-
|
|
{{ git_default_branch }}
|
|
accept_hostkey: false # should already have been accepted
|
|
key_file: '{{ github_ssh_private_key }}'
|
|
ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
|
|
register: git_result
|
|
when: github_ssh_private_key is defined
|
|
|
|
- assert:
|
|
that:
|
|
- git_result is changed
|
|
when: github_ssh_private_key is defined
|
|
|
|
- name: MISSING-HOSTEKY | Remove github.com hostkey from known_hosts
|
|
lineinfile:
|
|
dest: '{{ remote_tmp_dir }}/known_hosts'
|
|
regexp: "github.com"
|
|
state: absent
|
|
when: github_ssh_private_key is defined
|
|
|
|
- name: MISSING-HOSTKEY | clear checkout_dir
|
|
file:
|
|
state: absent
|
|
path: '{{ checkout_dir }}'
|
|
when: github_ssh_private_key is defined
|