Skip to content

Commit

Permalink
Sync develop to master (#120)
Browse files Browse the repository at this point in the history
<!-- Thanks for the contribution, this is awesome. -->

# PR Details
## Description
This is an intermediate branch cut from master which includes fixes to
the branch coupling of build and checkout scripts. This coupling can not
yet be removed from CI processes because this repository still uses
CircleCI. The functionality to decouple CI from branches is currently
only available through our GitHub actions
<!--- Describe your changes in detail -->

## Related GitHub Issue

<!--- This project only accepts pull requests related to open GitHub
issues or Jira Keys -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please DO NOT name partially fixed issues, instead open an issue
specific to this fix -->
<!--- Please link to the issue here: -->

## Related Jira Key

<!-- e.g. CAR-123 -->

## Motivation and Context
Decouple build/checkout from branch to make release process simpler
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
CI
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [ ] Defect fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that cause existing functionality
to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [ ] I have added any new packages to the sonar-scanner.properties file
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the
[**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md)
document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
  • Loading branch information
paulbourelly999 authored Apr 24, 2024
2 parents 6a18511 + 6f68568 commit d2060de
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 17 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
name: CI
on:
push:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- develop
- master
- "release/*"
jobs:
determine_docker_org_and_tag:
runs-on: ubuntu-latest
outputs:
docker_organization: ${{ steps.docker-org-and-tag.outputs.docker_organization }}
docker_image_tag: ${{ steps.docker-org-and-tag.outputs.docker_image_tag }}
steps:
- id: docker-org-and-tag
uses: usdot-fhwa-stol/actions/docker-org-and-tag@main
build:
needs: determine_docker_org_and_tag
defaults:
run:
shell: bash
working-directory: "/opt/carma/"
runs-on: ubuntu-latest
container:
image: usdotfhwastoldev/carma-base:develop
image: ${{ needs.determine_docker_org_and_tag.outputs.docker_organization }}/carma-base:${{ needs.determine_docker_org_and_tag.outputs.docker_image_tag }}
env:
INIT_ENV: "/home/carma/.base-image/init-env.sh"
ROS_2_ENV: "/opt/ros/foxy/setup.bash"
Expand All @@ -24,10 +38,18 @@ jobs:
path: src/${{ github.event.repository.name }}
- name: Move source code
run: mv $GITHUB_WORKSPACE/src /opt/carma/
- name: Determine base branch
id: determine-base-branch
run: |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
echo git_branch="$GITHUB_BASE_REF" >> $GITHUB_OUTPUT
else
echo git_branch="$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
fi
- name: Checkout dependencies
run: |
source "$INIT_ENV"
./src/${{ github.event.repository.name }}/docker/checkout.bash -r /opt/carma/
./src/${{ github.event.repository.name }}/docker/checkout.bash -r /opt/carma/ -b ${{ steps.determine-base-branch.outputs.git_branch }}
- name: Build
run: |
source "$INIT_ENV"
Expand All @@ -44,4 +66,4 @@ jobs:
uses: usdot-fhwa-stol/actions/sonar-scanner@main
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
working-dir: "/opt/carma/src/${{ github.event.repository.name }}"
working-dir: "/opt/carma/src/${{ github.event.repository.name }}"
8 changes: 8 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Docker build

on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
docker:
uses: usdot-fhwa-stol/actions/.github/workflows/docker.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Docker Hub build
on:
push:
branches:
- "develop"
- "master"
- "release/*"
tags:
- "carma-system-*"
jobs:
dockerhub:
uses: usdot-fhwa-stol/actions/.github/workflows/dockerhub.yml@main
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

FROM usdotfhwastoldev/carma-base:develop as setup
ARG DOCKER_ORG="usdotfhwastoldev"
ARG DOCKER_TAG="develop"
FROM ${DOCKER_ORG}/carma-base:${DOCKER_TAG} as base_image
FROM base_image as setup
ARG GIT_BRANCH="develop"

ARG ROS1_PACKAGES=""
ENV ROS1_PACKAGES=${ROS1_PACKAGES}
Expand All @@ -21,10 +24,10 @@ ENV ROS2_PACKAGES=${ROS2_PACKAGES}

RUN mkdir ~/src
COPY --chown=carma . /home/carma/src/
RUN ~/src/docker/checkout.bash
RUN ~/src/docker/checkout.bash -b ${GIT_BRANCH}
RUN ~/src/docker/install.sh

FROM usdotfhwastoldev/carma-base:develop
FROM setup

ARG BUILD_DATE="NULL"
ARG VERSION="NULL"
Expand Down
16 changes: 7 additions & 9 deletions docker/checkout.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
set -exo pipefail

dir=~
BRANCH=develop # The script will use this unless the -b flag updates it
while [[ $# -gt 0 ]]; do
arg="$1"
case $arg in
-d|--develop)
BRANCH=develop
-b|--branch)
BRANCH=$2
shift
shift
;;
-r|--root)
Expand All @@ -35,10 +37,6 @@ while [[ $# -gt 0 ]]; do
esac
done

if [[ "$BRANCH" = "develop" ]]; then
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch $BRANCH
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch $BRANCH
else
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch develop
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch develop
fi
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git "${dir}"/src/CARMAMsgs --branch "${BRANCH}"
git clone https://github.com/usdot-fhwa-stol/carma-utils.git "${dir}"/src/CARMAUtils --branch "${BRANCH}"

0 comments on commit d2060de

Please sign in to comment.