-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New action, new workflow test-pr using new action. New update-version…
… workflow
- Loading branch information
1 parent
9caad61
commit ec35bf1
Showing
3 changed files
with
96 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'With Docker' | ||
description: 'Run a given stage with Docker Image' | ||
inputs: | ||
container-version: | ||
description: 'Docker Image Version' | ||
required: true | ||
container-name: | ||
description: 'Docker Container Name' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 'Set up Docker' | ||
shell: bash {0} | ||
run: | | ||
set -euxo pipefail | ||
CONTAINER_NAME=${{inputs.container-name}} | ||
CONTAINER_VERSION=${{inputs.container-version}} | ||
docker run \ | ||
--name ${CONTAINER_NAME} \ | ||
--rm \ | ||
--interactive \ | ||
--tty \ | ||
--detach \ | ||
--user root \ | ||
--workdir /home/user/workspace \ | ||
runtimeverificationinc/kontrol:ubuntu-jammy-${CONTAINER_VERSION} | ||
# Copy the current Checkout direcotry into the container | ||
docker cp . ${CONTAINER_NAME}:/home/user/workspace | ||
docker exec ${CONTAINER_NAME} chown -R user:user /home/user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
name: 'Update Version' | ||
name: 'Test PR' | ||
on: | ||
pull_request: | ||
branches: | ||
|
@@ -11,52 +11,45 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
jobs: | ||
set-image-version: | ||
name: 'Set Image Version' | ||
runs-on: [self-hosted, linux, flyweight] | ||
outputs: | ||
image-version: ${{ steps.image-version.outputs.kontrol_version }} | ||
steps: | ||
- name: 'Check out code' | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 'Set Image Version' | ||
id: image-version | ||
run: | | ||
kontrol_version=$(cat deps/kontrol_release) | ||
echo "kontrol_version=${kontrol_version}" >> $GITHUB_ENV | ||
new-version-test: | ||
name: 'Test Tool Update' | ||
runs-on: [self-hosted, linux, normal] | ||
needs: [set-image-version] | ||
container: | ||
image: runtimeverificationinc/kontrol:ubuntu-jammy-${{ needs.set-image-version.outputs.image-version }} | ||
steps: | ||
- name: 'Check out code' | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.JENKINS_GITHUB_PAT }} | ||
fetch-depth: 0 | ||
|
||
- name: 'Configure GitHub user' | ||
- name: 'Get Kontrol Version' | ||
run: | | ||
git config user.name devops | ||
git config user.email [email protected] | ||
set -euo pipefail | ||
# Get the version of the tool from the Dockerfile | ||
echo "kontrol-version=$(cat deps/kontrol_release)" >> $GITHUB_ENV | ||
# Get Repository Base name | ||
echo "repository_basename=$(basename ${{ github.repository }})" >> $GITHUB_ENV | ||
- name: "Start Docker Container" | ||
uses: ./.github/actions/with-docker | ||
with: | ||
container-name: '${{ env.repository_basename }}-ci' | ||
container-version: '${{ env.kontrol-version }}' | ||
|
||
- name: 'Test New Tool Versions' | ||
run: | | ||
set -euo pipefail | ||
new-version=$(cat deps/kontrol_release) | ||
kup install --version ${new-version} | ||
# If all scripts in test.sh pass then the test is successful, else fail | ||
# and print the name of the script that failed | ||
for script in ./tests/*.sh; do | ||
if ! bash "$script"; then | ||
echo "Test failed: $script" | ||
exit 1 | ||
else | ||
echo "Test passed: $script" | ||
fi | ||
done | ||
# Run the following in the running docker container | ||
docker exec -u user ${{ env.repository_basename }}-ci bash -c ' | ||
set -euo pipefail | ||
# If all scripts in test.sh pass then the test is successful, else fail | ||
# and print the name of the script that failed | ||
# Print the tests folder | ||
ls -lR | ||
for script in ./tests/*.sh; do | ||
if ! bash "$script"; then | ||
echo "Test failed: $script" | ||
exit 1 | ||
else | ||
echo "Test passed: $script" | ||
fi | ||
done | ||
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'Update Version' | ||
on: | ||
push: | ||
branches: | ||
- '_update-deps/runtimeverification/kontrol' | ||
# Stop in progress workflows on the same branch and same workflow to use latest committed code | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
set-image-version: | ||
runs-on: [self-hosted, linux, flyweight] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.JENKINS_DEVOPS_TOKEN }} | ||
- name: Set image version | ||
run: | | ||
# Search replace previous version in .github/workflows/test-pr.yml with new version in deps/kontrol_release | ||
version=$(cat deps/kontrol_release) | ||
sed -i "s/kontrol:ubuntu-jammy-.*$/kontrol:ubuntu-jammy-${version}/g" .github/workflows/test-pr.yml | ||
git config --global user.name "DevOps" | ||
git config --global user.email "[email protected]" | ||
if [[ -z $(git status -s) ]]; then | ||
echo "No changes to commit" | ||
exit 0 | ||
fi | ||
else | ||
git add . | ||
git commit -m "Update kontrol image version to ${version}" | ||
git push origin HEAD:${{ github.ref }} | ||
fi |