Skip to content

Commit

Permalink
Add gitlab integration tests (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrie30 committed Jul 10, 2024
1 parent f6a01f6 commit 30ca6dd
Show file tree
Hide file tree
Showing 8 changed files with 449 additions and 102 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/gitlab-ee-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 53 additions & 54 deletions .github/workflows/go-build-test.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }}
19 changes: 19 additions & 0 deletions scripts/gitlab_cloud_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
4 changes: 2 additions & 2 deletions scripts/local-gitlab/get_credentials.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -xv

# poll until gitlab has started

Expand Down Expand Up @@ -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"

Expand Down
Loading

0 comments on commit 30ca6dd

Please sign in to comment.