Skip to content

Commit

Permalink
[202305] Checkout correct branch from sonic-mgmt-common and sonic-sws…
Browse files Browse the repository at this point in the history
…s-common during pipeline build (#128)

#### Why I did it

Pipeline is always fetching latest of sonic-mgmt-common and sonic-swss-common repos for its builds. They must be use source code from 202305 branch

#### How I did it

Checkout latest from `$(System.PullRequest.TargetBranch)` during PR builds and from `$(Build.SourceBranchName)` during manual builds.

Known issue: other pipeline artefacts are still being downloaded from master branch. Not a blocker as of now.

#### How to verify it

Pipeline build
  • Loading branch information
sachinholla authored Jul 6, 2023
1 parent 87d8eb3 commit 88ee65d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Semgrep

on:
pull_request: {}
push:
branches:
- master
- '201[7-9][0-1][0-9]'
- '202[0-9][0-1][0-9]'

jobs:
semgrep:
if: github.repository_owner == 'sonic-net'
name: Semgrep
runs-on: ubuntu-latest
container:
image: returntocorp/semgrep
steps:
- uses: actions/checkout@v3
- run: semgrep ci
env:
SEMGREP_RULES: p/default
19 changes: 9 additions & 10 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@ pr:
- 202???
- 201???

variables:
- name: BUILD_BRANCH
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
value: $(System.PullRequest.TargetBranch)
${{ else }}:
value: $(Build.SourceBranchName)

resources:
repositories:
- repository: sonic-mgmt-common
type: github
name: sonic-net/sonic-mgmt-common
endpoint: sonic-net
ref: refs/heads/$(BUILD_BRANCH)
- repository: sonic-swss-common
type: github
name: sonic-net/sonic-swss-common
endpoint: sonic-net
ref: refs/heads/$(BUILD_BRANCH)

stages:
- stage: Build
Expand Down Expand Up @@ -72,16 +81,6 @@ stages:
runBranch: 'refs/heads/master'
displayName: "Download sonic buildimage"

- task: DownloadPipelineArtifact@2
inputs:
source: specific
project: build
pipeline: 127
artifact: sonic-mgmt-common
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/master'
displayName: "Download sonic-mgmt-common"

- script: |
# PYTEST
sudo pip3 install -U pytest
Expand Down

0 comments on commit 88ee65d

Please sign in to comment.