-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(acctest): proper concurrency support
- Loading branch information
1 parent
41c6ce9
commit 43678bd
Showing
6 changed files
with
138 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
This directory contains the tests for some critical functionality of the GitHub Actions workflow. | ||
|
||
The tests are equivalent to the Bash scripts that are run in the workflow, but are atomic and can be run locally. | ||
|
||
## Structure | ||
|
||
The tests are organized into directories that correspond to the name of the workflow, | ||
and the atomic Bash scripts have the name of the job that they test. | ||
|
||
```text | ||
test | ||
├── README.md | ||
└── acceptance-tests | ||
├── README.md | ||
└── setup_aiven_project.sh | ||
└── ... | ||
└── run_tests.sh | ||
``` | ||
|
||
In the example above, the `acceptance-tests` directory contains the tests for the `acceptance-tests` workflow, | ||
and the `setup_aiven_project.sh` script tests the `setup_aiven_project` job. | ||
|
||
If a workflow has multiple jobs, then there will be multiple scripts in the directory. | ||
|
||
Let's say that the `some-other-workflow` workflow has two jobs, `some_other_job` and `some_other_job_2`. | ||
Then the directory structure would look like this: | ||
|
||
```text | ||
some-other-workflow/ | ||
├── README.md | ||
└── some_other_job.sh | ||
└── some_other_job_2.sh | ||
``` | ||
|
||
The `README.md` file in each directory contains a brief description of the workflow and the job that it tests. | ||
|
||
## Running the tests | ||
|
||
To run the tests, you need to execute the `run_tests.sh` script in the root directory. | ||
|
||
```bash | ||
./run_tests.sh | ||
``` | ||
|
||
The script will run all the tests that are available. | ||
|
||
Alternatively, you can run the tests by running the `Makefile` in the root directory of this repository. | ||
|
||
```bash | ||
make test-workflows | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
`acceptance-tests` is a directory that contains the tests for the `acceptance-tests` workflow. | ||
|
||
This workflow is responsible for running the acceptance tests for a specific branch. | ||
|
||
## Tests | ||
|
||
- `setup_aiven_project.sh` — This test sets up an Aiven project for the acceptance tests to run against. |
39 changes: 39 additions & 0 deletions
39
.github/workflows/test/acceptance-tests/setup_aiven_project.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
show_help() { | ||
echo "Usage: $0 -t AIVEN_TOKEN -p AIVEN_PROJECT_NAME" | ||
echo " -t AIVEN_TOKEN Set the Aiven API token." | ||
echo " -p AIVEN_PROJECT_NAME Set the Aiven Project Name prefix." | ||
echo " -h Show help." | ||
} | ||
|
||
while getopts 'ht:p:' flag; do | ||
case "${flag}" in | ||
t) AIVEN_TOKEN="${OPTARG}" ;; | ||
p) AIVEN_PROJECT_NAME="${OPTARG}" ;; | ||
h) show_help | ||
exit 0 ;; | ||
*) show_help | ||
exit 1 ;; | ||
esac | ||
done | ||
|
||
if [ -z "$AIVEN_TOKEN" ] || [ -z "$AIVEN_PROJECT_NAME" ]; then | ||
echo "Error: Aiven API token and Project Name prefix are required." | ||
show_help | ||
exit 1 | ||
fi | ||
|
||
response=$(curl -s -H "Authorization: Bearer $AIVEN_TOKEN" https://api.aiven.io/v1/project) | ||
|
||
projects=$(echo "$response" | \ | ||
jq --arg prefix "$AIVEN_PROJECT_NAME" '[.projects[] | select(.project_name | startswith($prefix))]') | ||
|
||
for project in $(echo "${projects}" | jq -r '.[].project_name'); do | ||
services=$(curl -s -H "Authorization: Bearer $AIVEN_TOKEN" \ | ||
"https://api.aiven.io/v1/project/$project/service") | ||
if [ "$(echo "$services" | jq '.services | length')" -eq 0 ]; then | ||
echo "Selected project: $project" | ||
break | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
./acceptance-tests/setup_aiven_project.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters