mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-06-11 17:13:04 +00:00
test(slug): test 'slug_ref' function
This commit is contained in:
committed by
Romain Lespinasse
parent
e461860662
commit
11ea6379cd
5
.github/actions/bats/Dockerfile
vendored
Normal file
5
.github/actions/bats/Dockerfile
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM dduportal/bats:latest
|
||||||
|
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
3
.github/actions/bats/entrypoint.sh
vendored
Executable file
3
.github/actions/bats/entrypoint.sh
vendored
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
/sbin/bats ./
|
||||||
17
.github/workflows/ci.yml
vendored
Normal file
17
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Tests
|
||||||
|
uses: ./.github/actions/bats
|
||||||
|
|
||||||
9
Makefile
Normal file
9
Makefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
help: ## print this message
|
||||||
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
.PHONY: tests
|
||||||
|
tests: ## Run tests locally
|
||||||
|
docker run -w /workdir -v $(shell pwd):/workdir dduportal/bats:latest ./
|
||||||
@@ -26,4 +26,4 @@ This action slug and expose some github variables.
|
|||||||
echo ${{ env.GITHUB_REF_SLUG }}
|
echo ${{ env.GITHUB_REF_SLUG }}
|
||||||
echo ${{ env.GITHUB_HEAD_REF_SLUG }}
|
echo ${{ env.GITHUB_HEAD_REF_SLUG }}
|
||||||
echo ${{ env.GITHUB_BASE_REF_SLUG }}
|
echo ${{ env.GITHUB_BASE_REF_SLUG }}
|
||||||
```
|
```
|
||||||
27
entrypoint-test.bats
Normal file
27
entrypoint-test.bats
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
@test "slug_ref" {
|
||||||
|
source entrypoint.sh
|
||||||
|
|
||||||
|
i=0
|
||||||
|
j=0
|
||||||
|
|
||||||
|
given[++i]="refs/head/master"
|
||||||
|
expected[++j]="master"
|
||||||
|
|
||||||
|
given[++i]="refs/head/feat/newFeature"
|
||||||
|
expected[++j]="newfeature"
|
||||||
|
|
||||||
|
given[++i]="refs/tags/v1.0"
|
||||||
|
expected[++j]="v1-0"
|
||||||
|
|
||||||
|
given[++i]="refs/head/awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters"
|
||||||
|
expected[++j]="awesome-feature-very-very-very-very-very-very-very-long-moretha"
|
||||||
|
|
||||||
|
for i in "${!given[@]}"
|
||||||
|
do
|
||||||
|
actual="$(slug_ref \"${given[i]}\")"
|
||||||
|
echo "expected : [${expected[i]}], actual : [${actual}]"
|
||||||
|
[ "$actual" == "${expected[i]}" ]
|
||||||
|
done
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user