Skip to content

Commit

Permalink
Merge pull request #34 from microsoft/dev
Browse files Browse the repository at this point in the history
Release 0.5.1
  • Loading branch information
Ndiritu authored Mar 6, 2023
2 parents d29e88d + dc87585 commit 3b4bd7d
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 7 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/auto-merge-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Auto-merge dependabot updates

on:
pull_request:
branches: [ main ]

permissions:
pull-requests: write
contents: write

jobs:

dependabot-merge:

runs-on: ubuntu-latest

if: ${{ github.actor == 'dependabot[bot]' }}

steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Enable auto-merge for Dependabot PRs
# Only if version bump is not a major version change
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
34 changes: 34 additions & 0 deletions .github/workflows/conflicting-pr-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This is a basic workflow to help you get started with Actions

name: PullRequestConflicting

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]
pull_request:
types: [synchronize]
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: check if prs are dirty
uses: eps1lon/actions-label-merge-conflict@releases/2.x
if: env.LABELING_TOKEN != '' && env.LABELING_TOKEN != null
id: check
with:
dirtyLabel: "conflicting"
repoToken: "${{ secrets.GITHUB_TOKEN }}"
continueOnMissingPermissions: true
commentOnDirty: 'This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.'
commentOnClean: 'Conflicts have been resolved. A maintainer will take a look shortly.'
env:
LABELING_TOKEN: ${{secrets.GITHUB_TOKEN }}
15 changes: 13 additions & 2 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,28 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.0', '8.1', '8.2']
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup PHP and Xdebug for Code Coverage report
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}
coverage: xdebug
- name: Install dependencies
run: composer install
- name: Run static analysis
run: ./vendor/bin/phpstan
- name: Run tests
run: ./vendor/bin/phpunit --coverage-text
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml
- name: Fix code coverage paths
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
- name: SonarCloud Scan
if: ${{ matrix.php-versions == '8.0' }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.org/microsoft/kiota-http-guzzle-php.svg?branch=main)](https://travis-ci.org/microsoft/kiota-http-guzzle-php)
[![Latest Stable Version](https://poser.pugx.org/microsoft/kiota-http-guzzle/version)](https://packagist.org/packages/microsoft/kiota-http-guzzle)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=microsoft_kiota-http-guzzle-php&metric=coverage)](https://sonarcloud.io/dashboard?id=microsoft_kiota-http-guzzle-php)

The Kiota HTTP Library for PHP is the PHP HTTP library implementation with [Guzzle](http://guzzlephp.org/).

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"php": "^7.4 | ^8.0",
"php-http/guzzle7-adapter": "^1.0",
"php-http/httplug": "^2.2",
"microsoft/kiota-abstractions": "0.5.0",
"microsoft/kiota-abstractions": "0.6.0",
"ext-zlib": "*",
"ext-json": "*"
},
Expand Down
5 changes: 5 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonar.projectKey=microsoft_kiota-http-guzzle-php
sonar.organization=microsoft
sonar.php.coverage.reportPaths=coverage.xml
sonar.sources=src/
sonar.tests=tests/
4 changes: 2 additions & 2 deletions src/GuzzleRequestAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private function throwFailedResponse(ResponseInterface $response, ?array $errorM
!($statusCode >= 400 && $statusCode < 500 && isset($errorMappings['4XX'])) &&
!($statusCode >= 500 && $statusCode < 600 && isset($errorMappings["5XX"])))) {
$ex = new ApiException("the server returned an unexpected status code and no error class is registered for this code " . $statusCode);
$ex->setResponse($response);
$ex->setResponseStatusCode($response->getStatusCode());
throw $ex;
}
/** @var array{string,string}|null $errorClass */
Expand All @@ -338,7 +338,7 @@ private function throwFailedResponse(ResponseInterface $response, ?array $errorM
$rootParseNode = $this->getRootParseNode($response);
$error = $rootParseNode->getObjectValue($errorClass);
if (is_subclass_of($error, ApiException::class)) {
$error->setResponse($response);
$error->setResponseStatusCode($response->getStatusCode());
throw $error;
}
throw new ApiException("Unsupported error type ". get_debug_type($error));
Expand Down
4 changes: 2 additions & 2 deletions src/Middleware/ChaosHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function __invoke(RequestInterface $request, array $options): PromiseInte
$this->chaosOption = $options[ChaosOption::class];
}

$randomPercentage = rand(0, ChaosOption::MAX_CHAOS_PERCENTAGE);
if ($randomPercentage < $this->chaosOption->getChaosPercentage()) {
$randomPercentage = rand(1, ChaosOption::MAX_CHAOS_PERCENTAGE);
if ($randomPercentage <= $this->chaosOption->getChaosPercentage()) {
$response = $this->randomChaosResponse($request, $options);
if ($response) {
return Create::promiseFor($response);
Expand Down

0 comments on commit 3b4bd7d

Please sign in to comment.