mirror of
https://github.com/gabrie30/ghorg.git
synced 2026-05-05 11:56:09 +02:00
Add gitlab integration tests (#434)
This commit is contained in:
parent
f6a01f63f6
commit
30ca6dd5d0
28
.github/workflows/gitlab-ee-integration-tests.yml
vendored
Normal file
28
.github/workflows/gitlab-ee-integration-tests.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
name: Run GitLab EE Integration Tests
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
gitlab_ee_integration_tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: "^1.20"
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Go dependencies and build the project
|
||||
run: |
|
||||
go mod download
|
||||
go install .
|
||||
- name: Add Go binaries to PATH
|
||||
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
- name: Set up Docker
|
||||
uses: docker-practice/actions-setup-docker@master
|
||||
- name: Add hosts to /etc/hosts
|
||||
run: |
|
||||
sudo echo "127.0.0.1 gitlab.example.com" | sudo tee -a /etc/hosts
|
||||
- name: Run GitLab Integration Test
|
||||
run: |
|
||||
echo "Using ghorg version: $(ghorg version)"
|
||||
export GHORG_GHA_CI=true
|
||||
./scripts/local-gitlab/start-ee.sh
|
||||
107
.github/workflows/go-build-test.yml
vendored
107
.github/workflows/go-build-test.yml
vendored
@ -1,6 +1,6 @@
|
||||
# Running locally https://yonatankra.com/how-to-test-github-actions-locally-using-act/
|
||||
name: Go
|
||||
on: [push, pull_request]
|
||||
on: pull_request
|
||||
jobs:
|
||||
build_and_test:
|
||||
environment: actions
|
||||
@ -10,61 +10,60 @@ jobs:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Set up Go 1.22
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.22
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
- name: Build
|
||||
run: go build -v -o ghorg .
|
||||
- name: Run GitHub Cloud Integration Tests
|
||||
run: scripts/github_cloud_integration_tests.sh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GHORG_GITHUB_TOKEN }}
|
||||
- name: Run Bitbucket Cloud Integration Tests
|
||||
run: scripts/bitbucket_cloud_integration_tests.sh
|
||||
env:
|
||||
BITBUCKET_TOKEN: ${{ secrets.GHORG_BITBUCKET_APP_PASSWORD }}
|
||||
BITBUCKET_USERNAME: ${{ secrets.GHORG_BITBUCKET_USERNAME }}
|
||||
- name: Run GitLab Cloud Integration Tests
|
||||
run: scripts/gitlab_cloud_integration_tests.sh
|
||||
env:
|
||||
GITLAB_TOKEN: ${{ secrets.GHORG_GITLAB_TOKEN }}
|
||||
|
||||
- name: Set up Go 1.22
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.22
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
- name: Build
|
||||
run: go build -v -o ghorg .
|
||||
- name: Run GitHub Cloud Integration Tests
|
||||
run: scripts/github_cloud_integration_tests.sh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GHORG_GITHUB_TOKEN }}
|
||||
- name: Run Bitbucket Cloud Integration Tests
|
||||
run: scripts/bitbucket_cloud_integration_tests.sh
|
||||
env:
|
||||
BITBUCKET_TOKEN: ${{ secrets.GHORG_BITBUCKET_APP_PASSWORD }}
|
||||
BITBUCKET_USERNAME: ${{ secrets.GHORG_BITBUCKET_USERNAME }}
|
||||
- name: Run GitLab Cloud Integration Tests
|
||||
run: scripts/gitlab_cloud_integration_tests.sh
|
||||
env:
|
||||
GITLAB_TOKEN: ${{ secrets.GHORG_GITLAB_TOKEN }}
|
||||
build_and_test_windows:
|
||||
environment: actions
|
||||
name: Build and Test Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Set up Go 1.22
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.22
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4
|
||||
- name: Set configuration file
|
||||
run: |
|
||||
mkdir C:\Users\runneradmin\.config\ghorg
|
||||
copy sample-conf.yaml C:\Users\runneradmin\.config\ghorg\conf.yaml
|
||||
- name: Build
|
||||
run: env GOOS=windows GOARCH=386 go build -v -o ghorg.exe .
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
- name: Run GitHub Integration Tests
|
||||
run: scripts/windows_github_integration_tests.bat
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GHORG_GITHUB_TOKEN }}
|
||||
- name: Run Bitbucket Integration Tests
|
||||
run: scripts/bitbucket_cloud_integration_tests.sh
|
||||
env:
|
||||
BITBUCKET_TOKEN: ${{ secrets.GHORG_BITBUCKET_APP_PASSWORD }}
|
||||
BITBUCKET_USERNAME: ${{ secrets.GHORG_BITBUCKET_USERNAME }}
|
||||
- name: Run GitLab Cloud Integration Tests
|
||||
run: scripts/gitlab_cloud_integration_tests.sh
|
||||
env:
|
||||
GITLAB_TOKEN: ${{ secrets.GHORG_GITLAB_TOKEN }}
|
||||
- name: Set up Go 1.22
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.22
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4
|
||||
- name: Set configuration file
|
||||
run: |
|
||||
mkdir C:\Users\runneradmin\.config\ghorg
|
||||
copy sample-conf.yaml C:\Users\runneradmin\.config\ghorg\conf.yaml
|
||||
- name: Build
|
||||
run: env GOOS=windows GOARCH=386 go build -v -o ghorg.exe .
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
- name: Run GitHub Integration Tests
|
||||
run: scripts/windows_github_integration_tests.bat
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GHORG_GITHUB_TOKEN }}
|
||||
- name: Run Bitbucket Integration Tests
|
||||
run: scripts/bitbucket_cloud_integration_tests.sh
|
||||
env:
|
||||
BITBUCKET_TOKEN: ${{ secrets.GHORG_BITBUCKET_APP_PASSWORD }}
|
||||
BITBUCKET_USERNAME: ${{ secrets.GHORG_BITBUCKET_USERNAME }}
|
||||
- name: Run GitLab Cloud Integration Tests
|
||||
run: scripts/gitlab_cloud_integration_tests.sh
|
||||
env:
|
||||
GITLAB_TOKEN: ${{ secrets.GHORG_GITLAB_TOKEN }}
|
||||
@ -95,6 +95,25 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# SNIPPETS
|
||||
# ghorg clone $GITLAB_GROUP_2 --token="${GITLAB_TOKEN}" --scm=gitlab --clone-snippets --preserve-dir
|
||||
|
||||
# if [ -e "${HOME}"/ghorg/"${GITLAB_GROUP_2}"/subgroup-2/foobar.snippets/test-snippet-2-3711655 ]
|
||||
# then
|
||||
# echo "Pass: gitlab group clone snippet 2 with preserve dir"
|
||||
# else
|
||||
# echo "Fail: gitlab group clone snippet 2 with preserve dir"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# if [ -e "${HOME}"/ghorg/"${GITLAB_GROUP_2}"/subgroup-2/foobar.snippets/test-snippet-1-3711654 ]
|
||||
# then
|
||||
# echo "Pass: gitlab group clone snippet 1 with preserve dir"
|
||||
# else
|
||||
# echo "Fail: gitlab group clone snippet 1 with preserve dir"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
#
|
||||
# SUBGROUP TESTS
|
||||
#
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -xv
|
||||
|
||||
# poll until gitlab has started
|
||||
|
||||
@ -29,7 +29,7 @@ done
|
||||
|
||||
set -x
|
||||
|
||||
docker exec -it gitlab gitlab-rails runner "token = User.find_by_username('root').personal_access_tokens.create(scopes: [:api, :read_api, :sudo], name: 'CI Test Token'); token.set_token('password'); token.save!"
|
||||
docker exec gitlab gitlab-rails runner "token = User.find_by_username('root').personal_access_tokens.create(scopes: [:api, :read_api, :sudo], name: 'CI Test Token', expires_at: 365.days.from_now); token.set_token('password'); token.save!"
|
||||
|
||||
API_TOKEN="password"
|
||||
|
||||
|
||||
@ -1,12 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
set -xv
|
||||
|
||||
LOCAL_GITLAB_GHORG_DIR=${1:-"${HOME}/ghorg"}
|
||||
TOKEN=${2:-'password'}
|
||||
GITLAB_URL=${3:-'http://gitlab.example.com'}
|
||||
|
||||
|
||||
# Delete all folders that start with local-gitlab-v15- in the LOCAL_GITLAB_GHORG_DIR
|
||||
for dir in "${LOCAL_GITLAB_GHORG_DIR}"/local-gitlab-*; do
|
||||
if [ -d "$dir" ]; then
|
||||
rm -rf "$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
TOKEN=${1:-'password'}
|
||||
GITLAB_URL=${2:-'http://gitlab.example.com'}
|
||||
LOCAL_GITLAB_GHORG_DIR=${3:-"${HOME}/ghorg"}
|
||||
|
||||
export GHORG_INSECURE_GITLAB_CLIENT=true
|
||||
# export GHORG_DEBUG=true
|
||||
|
||||
# NOTE run all clones twice to test once for clone then pull
|
||||
|
||||
@ -36,7 +46,7 @@ EOF
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "CLONE AND TEST ALL-GROUPS, PRESERVE DIR, OUTPUT DIR TEST FAILED"
|
||||
echo "CLONE AND TEST ALL-GROUPS, PRESERVE DIR, OUTPUT DIR TEST FAILED local-gitlab-group1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -51,7 +61,7 @@ EOF
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "CLONE AND TEST ALL-GROUPS, PRESERVE DIR, OUTPUT DIR TEST FAILED"
|
||||
echo "CLONE AND TEST ALL-GROUPS, PRESERVE DIR, OUTPUT DIR TEST FAILED local-gitlab-group2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -67,7 +77,7 @@ EOF
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "CLONE AND TEST ALL-GROUPS, PRESERVE DIR, OUTPUT DIR TEST FAILED"
|
||||
echo "CLONE AND TEST ALL-GROUPS, PRESERVE DIR, OUTPUT DIR TEST FAILED local-gitlab-group3/subgroup-a"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -77,7 +87,6 @@ ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}
|
||||
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos-flat | grep -o 'local-gitlab-v15-repos-flat.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-repos-flat/Monitoring
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group1_baz0
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group1_baz1
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group1_baz2
|
||||
@ -103,6 +112,131 @@ echo "CLONE AND TEST ALL-GROUPS, OUTPUT DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
########### CLONE AND TEST ALL-GROUPS, OUTPUT DIR, WIKI ############
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --clone-wiki --output-dir=local-gitlab-v15-repos-flat-wiki
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --clone-wiki --output-dir=local-gitlab-v15-repos-flat-wiki
|
||||
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos-flat-wiki | grep -o 'local-gitlab-v15-repos-flat-wiki.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz0
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz0.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz1
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz1.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz2
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz2.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz3
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group1_baz3.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz0
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz0.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz1
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz1.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz2
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz2.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz3
|
||||
local-gitlab-v15-repos-flat-wiki/local-gitlab-group2_baz3.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_0
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_0.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_1
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_1.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_2
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_2.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_3
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_a_repo_3.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_0
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_0.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_1
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_1.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_2
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_2.wiki
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_3
|
||||
local-gitlab-v15-repos-flat-wiki/subgroup_b_repo_3.wiki
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "CLONE AND TEST ALL-GROUPS, OUTPUT DIR, WIKI"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ########### CLONE AND TEST ALL-GROUPS, OUTPUT DIR, WIKI, SNIPPETS ############
|
||||
# ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --clone-wiki --clone-snippets --output-dir=local-gitlab-v15-repos-flat-wiki-snippets
|
||||
# ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --clone-wiki --clone-snippets --output-dir=local-gitlab-v15-repos-flat-wiki-snippets
|
||||
|
||||
# GOT=$( ghorg ls local-gitlab-v15-repos-flat-wiki-snippets | grep -o 'local-gitlab-v15-repos-flat-wiki-snippets.*')
|
||||
# WANT=$(cat <<EOF
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/_ghorg_root_level_snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz0
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz0.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz1
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz1.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz2
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz2.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz3
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group1_baz3.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz0
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz0.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz0.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz1
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz1.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz1.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz2
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz2.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz2.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz3
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz3.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/local-gitlab-group2_baz3.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_0
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_0.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_0.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_1
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_1.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_1.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_2
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_2.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_2.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_3
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_3.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_a_repo_3.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_0
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_0.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_0.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_1
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_1.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_1.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_2
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_2.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_2.wiki
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_3
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_3.snippets
|
||||
# local-gitlab-v15-repos-flat-wiki-snippets/subgroup_b_repo_3.wiki
|
||||
# EOF
|
||||
# )
|
||||
|
||||
# if [ "${WANT}" != "${GOT}" ]
|
||||
# then
|
||||
# echo "CLONE AND TEST ALL-GROUPS, OUTPUT DIR, WIKI, AND SNIPPETS"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# ############ CLONE AND TEST ALL-GROUPS, OUTPUT DIR, SNIPPETS, ROOT LEVEL ############
|
||||
# ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="$TOKEN" --preserve-dir --clone-snippets --output-dir=local-gitlab-v15-snippets-preserve-dir-output-dir-all-groups
|
||||
# ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="$TOKEN" --preserve-dir --clone-snippets --output-dir=local-gitlab-v15-snippets-preserve-dir-output-dir-all-groups
|
||||
|
||||
# # Test root level snippets
|
||||
# GOT=$( ghorg ls local-gitlab-v15-snippets-preserve-dir-output-dir-all-groups/_ghorg_root_level_snippets | grep -o 'local-gitlab-v15-snippets-preserve-dir-output-dir-all-groups.*')
|
||||
# WANT=$(cat <<EOF
|
||||
# local-gitlab-v15-snippets-preserve-dir-output-dir-all-groups/_ghorg_root_level_snippets/snippet1-1
|
||||
# local-gitlab-v15-snippets-preserve-dir-output-dir-all-groups/_ghorg_root_level_snippets/snippet2-2
|
||||
# EOF
|
||||
# )
|
||||
|
||||
# if [ "${WANT}" != "${GOT}" ]
|
||||
# then
|
||||
# echo "CLONE AND TEST ALL-GROUPS, OUTPUT DIR, SNIPPETS, ROOT LEVEL FAILED"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
############ CLONE ALL-GROUPS, BACKUP, CLONE WIKI, OUTPUT DIR ############
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --clone-wiki --output-dir=local-gitlab-v15-backup
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --clone-wiki --output-dir=local-gitlab-v15-backup
|
||||
@ -120,6 +254,27 @@ ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}
|
||||
ghorg clone root --clone-type=user --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-root-user-repos --prune --prune-no-confirm
|
||||
ghorg clone root --clone-type=user --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-root-user-repos --prune --prune-no-confirm
|
||||
|
||||
# ############ CLONE SINGLE USER, OUTPUT DIR, SNIPPETS ############
|
||||
# ghorg clone root --clone-type=user --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --clone-snippets --output-dir=local-gitlab-v15-root-user-repos-snippets
|
||||
# ghorg clone root --clone-type=user --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --clone-snippets --output-dir=local-gitlab-v15-root-user-repos-snippets
|
||||
|
||||
# # Test root level snippets
|
||||
# GOT=$( ghorg ls local-gitlab-v15-root-user-repos-snippets | grep -o 'local-gitlab-v15-root-user-repos-snippets.*')
|
||||
# WANT=$(cat <<EOF
|
||||
# local-gitlab-v15-root-user-repos-snippets/rootrepos0
|
||||
# local-gitlab-v15-root-user-repos-snippets/rootrepos1
|
||||
# local-gitlab-v15-root-user-repos-snippets/rootrepos1.snippets
|
||||
# local-gitlab-v15-root-user-repos-snippets/rootrepos2
|
||||
# local-gitlab-v15-root-user-repos-snippets/rootrepos3
|
||||
# EOF
|
||||
# )
|
||||
|
||||
# if [ "${WANT}" != "${GOT}" ]
|
||||
# then
|
||||
# echo "CLONE AND TEST ALL-GROUPS, OUTPUT DIR, SNIPPETS, ROOT LEVEL FAILED"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
####### ####### ###### # ####### # # ####### # ##### ###### ####### # # ######
|
||||
# # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # #
|
||||
@ -138,19 +293,19 @@ ghorg clone local-gitlab-group1 --scm=gitlab --base-url="${GITLAB_URL}" --token=
|
||||
ghorg clone local-gitlab-group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group1
|
||||
|
||||
############ CLONE AND TEST TOP LEVEL GROUP ############
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}"
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}"
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-top-level-group
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-top-level-group
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-group3 | grep -o 'local-gitlab-group3.*')
|
||||
GOT=$(ghorg ls local-gitlab-v15-top-level-group | grep -o 'local-gitlab-v15-top-level-group.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-group3/subgroup_a_repo_0
|
||||
local-gitlab-group3/subgroup_a_repo_1
|
||||
local-gitlab-group3/subgroup_a_repo_2
|
||||
local-gitlab-group3/subgroup_a_repo_3
|
||||
local-gitlab-group3/subgroup_b_repo_0
|
||||
local-gitlab-group3/subgroup_b_repo_1
|
||||
local-gitlab-group3/subgroup_b_repo_2
|
||||
local-gitlab-group3/subgroup_b_repo_3
|
||||
local-gitlab-v15-top-level-group/subgroup_a_repo_0
|
||||
local-gitlab-v15-top-level-group/subgroup_a_repo_1
|
||||
local-gitlab-v15-top-level-group/subgroup_a_repo_2
|
||||
local-gitlab-v15-top-level-group/subgroup_a_repo_3
|
||||
local-gitlab-v15-top-level-group/subgroup_b_repo_0
|
||||
local-gitlab-v15-top-level-group/subgroup_b_repo_1
|
||||
local-gitlab-v15-top-level-group/subgroup_b_repo_2
|
||||
local-gitlab-v15-top-level-group/subgroup_b_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
@ -225,6 +380,26 @@ fi
|
||||
|
||||
rm -rf "${LOCAL_GITLAB_GHORG_DIR}"/local-gitlab-group3
|
||||
|
||||
# ############ CLONE AND TEST TOP LEVEL GROUP WITH NESTED SUBGROUP, PRESERVE DIR, SNIPPETS ############
|
||||
# ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --clone-snippets --output-dir=local-gitlab-v15-group-3-perserve-snippets
|
||||
# ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --clone-snippets --output-dir=local-gitlab-v15-group-3-perserve-snippets
|
||||
|
||||
# GOT=$(ghorg ls local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-group3/subgroup-a.*')
|
||||
# WANT=$(cat <<EOF
|
||||
# local-gitlab-group3/subgroup-a/subgroup-b
|
||||
# local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
# local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
# local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
# local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
# EOF
|
||||
# )
|
||||
|
||||
# if [ "${WANT}" != "${GOT}" ]
|
||||
# then
|
||||
# echo "TEST GROUP WITH SUBGROUP WITH PRESERVE DIR OUTPUT DIR SNIPPETS FAILED"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
|
||||
##### # # ###### ##### ###### ####### # # ######
|
||||
# # # # # # # # # # # # # # # #
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -xv
|
||||
|
||||
# Note: you will need to stop manually
|
||||
# docker stop gitlab
|
||||
# docker rm gitlab
|
||||
@ -17,6 +19,12 @@ PERSIST_GITLAB_LOCALLY=$4
|
||||
echo ""
|
||||
echo "Starting fresh install of GitLab Enterprise Edition, using tag: ${GITLAB_IMAGE_TAG}"
|
||||
|
||||
if [ "${GHORG_GHA_CI}" == "true" ]; then
|
||||
GHORG_SSH_PORT=2222
|
||||
else
|
||||
GHORG_SSH_PORT=22
|
||||
fi
|
||||
|
||||
|
||||
if [ "${PERSIST_GITLAB_LOCALLY}" == "true" ];then
|
||||
echo "Removing any previous install at path: ${GITLAB_HOME}"
|
||||
@ -27,7 +35,7 @@ if [ "${PERSIST_GITLAB_LOCALLY}" == "true" ];then
|
||||
docker run \
|
||||
-d=true \
|
||||
--hostname "${GITLAB_HOST}" \
|
||||
--publish 443:443 --publish 80:80 --publish 22:22 \
|
||||
--publish 443:443 --publish 80:80 --publish "${GHORG_SSH_PORT}":22 \
|
||||
--name gitlab \
|
||||
gitlab/gitlab-ee:"${GITLAB_IMAGE_TAG}"
|
||||
else
|
||||
@ -35,7 +43,7 @@ else
|
||||
docker run \
|
||||
-d=true \
|
||||
--hostname "${GITLAB_HOST}" \
|
||||
--publish 443:443 --publish 80:80 --publish 22:22 \
|
||||
--publish 443:443 --publish 80:80 --publish "${GHORG_SSH_PORT}":22 \
|
||||
--name gitlab \
|
||||
gitlab/gitlab-ee:"${GITLAB_IMAGE_TAG}"
|
||||
fi
|
||||
|
||||
@ -1,61 +1,128 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -xv
|
||||
|
||||
# https://docs.gitlab.com/ee/install/docker.html#install-gitlab-using-docker-engine
|
||||
|
||||
TOKEN=$1
|
||||
GITLAB_URL=$2
|
||||
LOCAL_GITLAB_GHORG_DIR=$3
|
||||
|
||||
# Create 3 groups, namespace_id will start at 4 (same thing as Group ID you can find in the UI)
|
||||
# Create 3 groups, namespace_id will start at 2 (same thing as Group ID you can find in the UI)
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "local-gitlab-group1", "name": "local-gitlab-group1" }' \
|
||||
"${GITLAB_URL}/api/v4/groups"
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
GROUP1_NAMESPACE_ID=$(curl --request GET --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
"${GITLAB_URL}/api/v4/namespaces/local-gitlab-group1" | jq '.id')
|
||||
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "local-gitlab-group2", "name": "local-gitlab-group2" }' \
|
||||
"${GITLAB_URL}/api/v4/groups"
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
GROUP2_NAMESPACE_ID=$(curl --request GET --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
"${GITLAB_URL}/api/v4/namespaces/local-gitlab-group2" | jq '.id')
|
||||
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "local-gitlab-group3", "name": "local-gitlab-group3" }' \
|
||||
"${GITLAB_URL}/api/v4/groups"
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
GROUP3_NAMESPACE_ID=$(curl --request GET --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
"${GITLAB_URL}/api/v4/namespaces/local-gitlab-group3" | jq '.id')
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# group3/subgroup-a
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "subgroup-a", "name": "subgroup-a" }' \
|
||||
"${GITLAB_URL}/api/v4/groups?parent_id=6"
|
||||
"${GITLAB_URL}/api/v4/groups?parent_id=${GROUP3_NAMESPACE_ID}"
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
GROUP3_SUBGROUPA_NAMESPACE_ID=$(curl --request GET --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
"${GITLAB_URL}/api/v4/namespaces/local-gitlab-group3%2Fsubgroup-a" | jq '.id')
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# group3/subgroup-a/subgroup-b
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "subgroup-b", "name": "subgroup-b" }' \
|
||||
"${GITLAB_URL}/api/v4/groups?parent_id=7"
|
||||
"${GITLAB_URL}/api/v4/groups?parent_id=${GROUP3_SUBGROUPA_NAMESPACE_ID}"
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 2
|
||||
|
||||
GROUP3_SUBGROUPA_SUBGROUPB_NAMESPACE_ID=$(curl --request GET --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
"${GITLAB_URL}/api/v4/namespaces/local-gitlab-group3%2Fsubgroup-a%2Fsubgroup-b" | jq '.id')
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# Create 2 users
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"email": "testuser1@example.com", "password": "adminadmin1","name": "testuser1","username": "testuser1",reset_password": "true" }' \
|
||||
--data '{"email": "testuser1@example.com", "password": "adminadmin1","name": "testuser1","username": "testuser1"}' \
|
||||
"${GITLAB_URL}/api/v4/users"
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"email": "testuser2@example.com", "password": "adminadmin1","name": "testuser2","username": "testuser2","reset_password": "true" }' \
|
||||
--data '{"email": "testuser2@example.com", "password": "adminadmin1","name": "testuser2","username": "testuser2"}' \
|
||||
"${GITLAB_URL}/api/v4/users"
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# create repos for root user
|
||||
for ((a=0; a <= 3 ; a++))
|
||||
@ -63,38 +130,89 @@ do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=rootrepos${a}&initialize_with_readme=true"
|
||||
done
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# create repos in group1
|
||||
for ((a=0; a <= 3 ; a++))
|
||||
do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=baz${a}&namespace_id=4&initialize_with_readme=true"
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=baz${a}&namespace_id=${GROUP1_NAMESPACE_ID}&initialize_with_readme=true"
|
||||
done
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# create repos in group2
|
||||
# create snippets at the root level
|
||||
for ((a=1; a <= 2 ; a++))
|
||||
do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/snippets?title=snippet${a}&file_name=file${a}&content=content${a}&description=description${a}&visibility=public"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# create repos and snippets in group2
|
||||
for ((a=0; a <= 3 ; a++))
|
||||
do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=baz${a}&namespace_id=5&initialize_with_readme=true"
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=baz${a}&namespace_id=${GROUP2_NAMESPACE_ID}&initialize_with_readme=true"
|
||||
sleep 1
|
||||
# Create non-empty snippet for the repo
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"title": "Snippet for subgroup_a_repo_'${a}'", "file_name": "snippet.txt", "content": "This is a snippet for subgroup_a_repo_'${a}'", "visibility": "public"}' \
|
||||
"${GITLAB_URL}/api/v4/projects/local-gitlab-group2%2Fbaz${a}/snippets"
|
||||
done
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# create repos in group3/subgroup-a
|
||||
# create repos and snippets in group3/subgroup-a
|
||||
for ((a=0; a <= 3 ; a++))
|
||||
do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=subgroup_a_repo_${a}&namespace_id=7&initialize_with_readme=true"
|
||||
# Create repo
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=subgroup_a_repo_${a}&namespace_id=${GROUP3_SUBGROUPA_NAMESPACE_ID}&initialize_with_readme=true"
|
||||
echo ""
|
||||
sleep 1
|
||||
# Create non-empty snippet for the repo
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"title": "Snippet for subgroup_a_repo_'${a}'", "file_name": "snippet.txt", "content": "This is a snippet for subgroup_a_repo_'${a}'", "visibility": "public"}' \
|
||||
"${GITLAB_URL}/api/v4/projects/local-gitlab-group3%2Fsubgroup-a%2Fsubgroup_a_repo_${a}/snippets"
|
||||
done
|
||||
|
||||
sleep 5
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
# create repos in group3/subgroup-a/subgroup-b
|
||||
# create repos and snippets in group3/subgroup-a/subgroup-b
|
||||
for ((a=0; a <= 3 ; a++))
|
||||
do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=subgroup_b_repo_${a}&namespace_id=8&initialize_with_readme=true"
|
||||
# Create repo
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=subgroup_b_repo_${a}&namespace_id=${GROUP3_SUBGROUPA_SUBGROUPB_NAMESPACE_ID}&initialize_with_readme=true"
|
||||
echo ""
|
||||
sleep 1
|
||||
# Create non-empty snippet for the repo
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"title": "Snippet for subgroup_b_repo_'${a}'", "file_name": "snippet.txt", "content": "This is a snippet for subgroup_b_repo_'${a}'", "visibility": "public"}' \
|
||||
"${GITLAB_URL}/api/v4/projects/local-gitlab-group3%2Fsubgroup-a%2Fsubgroup-b%2Fsubgroup_b_repo_${a}/snippets"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 1
|
||||
|
||||
echo "sleeping before running integration tests, to ensure all resources are created"
|
||||
sleep 5
|
||||
|
||||
./scripts/local-gitlab/integration-tests.sh "${TOKEN}" "${GITLAB_URL}" "${LOCAL_GITLAB_GHORG_DIR}"
|
||||
./scripts/local-gitlab/integration-tests.sh "${LOCAL_GITLAB_GHORG_DIR}" "${TOKEN}" "${GITLAB_URL}"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -xv
|
||||
|
||||
STOP_GITLAB_WHEN_FINISHED=${1:-'true'}
|
||||
PERSIST_GITLAB_LOCALLY=${2:-'false'}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user