Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Install SonarCloud scanner and run analysis
uses: SonarSource/sonarcloud-github-action@master
if: (github.event_name == 'pull_request' || github.ref_type == 'branch') && !github.event.pull_request.head.repo.fork
if: (github.event_name == 'pull_request' || github.ref_type == 'branch') && !github.event.pull_request.head.repo.fork && startsWith(matrix.language, 'csharp') != true
with:
projectBaseDir: examples/${{ matrix.language }}
env:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ generate: install
bash scripts/generate.sh

test-docker: generate
bash scripts/prism.sh $(SONAR_TOKEN)
bash scripts/prism.sh
23 changes: 12 additions & 11 deletions examples/csharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG SONAR_TOKEN=""
ENV PATH="${PATH}:/root/.dotnet/tools"

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
build-essential \
mono-complete \
openjdk-11-jre

RUN dotnet tool install --global dotnet-sonarscanner \
&& dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.8.12

RUN dotnet tool list -g
ENV PATH="${PATH}:/root/.dotnet/tools"
ENV SONAR_TOKEN=$SONAR_TOKEN
&& dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.8.12 \
&& dotnet tool list -g

RUN mkdir /app
WORKDIR /app
Expand All @@ -24,9 +23,11 @@ COPY src/Twilio/Rest src/Twilio/Rest
RUN rm -rf test/Twilio.Test/*/ test/Twilio.Test/*Cluster*
COPY unit-test/Rest integrationTest/Rest test/Twilio.Test/

RUN dotnet restore
RUN dotnet build Twilio.sln
CMD ["/bin/bash", "-c", "set -o pipefail && sleep 10 && dotnet test test/Twilio.Test/Twilio.Test.csproj --no-build 2>&1 | tee /local/test-report.out"]
RUN make install

COPY test.sh .
ARG SONAR_TOKEN
ENV SONAR_TOKEN=$SONAR_TOKEN

RUN apt-get -y install build-essential
CMD if [ "$SONAR_TOKEN" = "" ] ; then echo Skipping sonar analysis ; else make cover PROJECT_NAME=twilio_twilio-oai-generator-csharp SONAR_SOURCES="/d:sonar.inclusions=src/Twilio/Rest/**/* /d:sonar.cs.analyzeGeneratedCode=true /d:sonar.exclusions=test/Twilio.Test/**/*" ; fi
# pipefail prevents errors in a pipeline from being masked.
CMD ["/bin/bash", "-c", "set -o pipefail && chmod u+r+x test.sh && /app/twilio-csharp/test.sh 2>&1 | tee /local/test-report.out"]
2 changes: 1 addition & 1 deletion examples/csharp/integrationTest/Rest/ApiIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void TestCustomTypes()
[Test]
public void TestPost()
{
var call = CallResource.Create("testString", ACCOUNT_SID);
var call = CallResource.Create("testString", Twilio.Http.HttpMethod.Post , ACCOUNT_SID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Assert.NotNull(call);
Assert.AreEqual("Ahoy", call.TestString);
}
Expand Down
11 changes: 11 additions & 0 deletions examples/csharp/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

sleep 10

if [ "$SONAR_TOKEN" = "" ]; then
make test
else
make cover PROJECT_NAME=twilio_twilio-oai-generator-csharp \
SONAR_SOURCES="/d:sonar.inclusions=src/Twilio/Rest/**/* /d:sonar.cs.analyzeGeneratedCode=true /d:sonar.exclusions=test/Twilio.Test/**/*"
fi
2 changes: 2 additions & 0 deletions examples/prism/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ services:
csharp-test:
build:
context: ../csharp
args:
- SONAR_TOKEN
volumes:
- ../csharp:/local
depends_on:
Expand Down
20 changes: 11 additions & 9 deletions scripts/prism.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

LANGUAGES=${LANGUAGES:-go java node csharp php}

for library in ${LANGUAGES}; do
testing_services+=("${library}-test")
for language in ${LANGUAGES}; do
testing_services+=("${language}-test")
done

cd examples/prism
Expand All @@ -13,9 +13,9 @@ docker-compose up -d --force-recreate --remove-orphans "${testing_services[@]}"

function wait_for() {
echo -n "Waiting for tests to complete"
for docker_test_service in "$@"; do
for language in ${LANGUAGES}; do
while true; do
if [[ "$(docker-compose ps -q "$docker_test_service" | xargs docker inspect -f "{{.State.Status}}")" != "exited" ]]; then
if [[ "$(docker-compose ps -q "${language}-test" | xargs docker inspect -f "{{.State.Status}}")" != "exited" ]]; then
echo -n "."
sleep 10
else
Expand All @@ -28,17 +28,19 @@ function wait_for() {

EXIT_CODE=0
function check_status() {
for docker_test_service in "$@"; do
for language in ${LANGUAGES}; do
docker_test_service="${language}-test"
if [[ $(docker-compose ps -q "$docker_test_service" | xargs docker inspect -f "{{.State.ExitCode}}") -ne 0 ]]; then
EXIT_CODE=$(($EXIT_CODE || $(docker-compose ps -q "$docker_test_service" | xargs docker inspect -f "{{.State.ExitCode}}")))
echo "Failed $docker_test_service with EXIT code $(docker-compose ps -q "$docker_test_service" | xargs docker inspect -f "{{.State.ExitCode}}")"
echo "Failed $language with EXIT code $(docker-compose ps -q "$docker_test_service" | xargs docker inspect -f "{{.State.ExitCode}}")"
cat "../${language}/test-report.out"
else
echo "$docker_test_service completed successfully"
echo "$language completed successfully"
fi
done
}

wait_for "${testing_services[@]}"
check_status "${testing_services[@]}"
wait_for
check_status
docker-compose down
exit $EXIT_CODE