Skip to content

Commit

Permalink
Moved CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Oct 15, 2023
1 parent 25b055c commit cd510dc
Show file tree
Hide file tree
Showing 13 changed files with 1,066 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/dependent-repositories.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include" : [
{ "repository" : "OpenPonk/class-editor", "branch" : "master", "build-dependent" : true },
{ "repository" : "OpenPonk/borm-editor", "branch" : "master", "build-dependent" : false },
{ "repository" : "OpenPonk/petrinets", "branch" : "master", "build-dependent" : false },
{ "repository" : "OpenPonk/fsm-editor", "branch" : "master", "build-dependent" : false },
{ "repository" : "OpenPonk/OpenPonk-BPMN", "branch" : "master", "build-dependent" : false },
{ "repository" : "OpenPonk/markov-chains", "branch" : "main", "build-dependent" : false }
]
}
54 changes: 54 additions & 0 deletions .github/scripts/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

set -euxo pipefail

ci_build_dir=$SMALLTALK_CI_BUILD
package_dir="$PROJECT_NAME-$PLATFORM"
vm_dir=`cat $SMALLTALK_CI_VM | sed 's|\(.*\)/.*|\1|'`/pharo-vm

mkdir -p "$package_dir/image"
mkdir -p "$package_dir/pharo"

cp $ci_build_dir/TravisCI.image $package_dir/image/$PROJECT_NAME.image
cp $ci_build_dir/TravisCI.changes $package_dir/image/$PROJECT_NAME.changes
cp $ci_build_dir/*.sources $package_dir/image

cp -r $vm_dir/bin $package_dir/pharo/bin
cp -r $vm_dir/lib $package_dir/pharo/lib

cat << EOF > $package_dir/$PROJECT_NAME
#!/bin/bash
\`dirname "\$0"\`/pharo/bin/pharo \`dirname "\$0"\`/image/$PROJECT_NAME.image
EOF

cat << EOF > $package_dir/$PROJECT_NAME-pharo-ui
#!/bin/bash
pharo-ui \`dirname "\$0"\`/image/$PROJECT_NAME.image
EOF

cat << EOF > $package_dir/README.txt
# Installation and Opening
To run OpenPonk on Debian-based, Ubuntu-based and possibly other Linux distros, simply use $PROJECT_NAME executable.
## In case of errors/exceptions
OpenPonk might encounter some error when used with some Linux distros. In that case, installation of Pharo programming language is required (sudo privileges needed).
1. Open Pharo builds website: https://software.opensuse.org//download.html?project=devel:languages:pharo:stable&package=pharo-ui
2. Select your Linux distribution.
3. Select "Add repository and install manually".
4. Follow shown instruction if any and execute shown bash code in terminal - one line at a time.
You might need to prepend "sudo" before each line.
If your distro version number does not match given options, try manually changing the version number/name in shown code.
After Pharo is installed, you may run OpenPonk using $PROJECT_NAME-pharo-ui executable.
EOF

cat "ci-scripts/.github/scripts/readmecommon.txt" >> "$package_dir/README.txt"

chmod a+rx $package_dir/$PROJECT_NAME $package_dir/$PROJECT_NAME-pharo-ui

"$vm_dir/bin/pharo" --headless $package_dir/image/$PROJECT_NAME.image eval --save "PharoCommandLineHandler forcePreferencesOmission: true. OPVersion currentWithRunId: $RUN_ID projectName: '$REPOSITORY_NAME'"

zip -qr $PROJECT_NAME-$PLATFORM-$VERSION.zip $package_dir
96 changes: 96 additions & 0 deletions .github/scripts/build-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

set -euxo pipefail

ci_build_dir=$SMALLTALK_CI_BUILD
package_dir="$PROJECT_NAME-$PLATFORM"
vm_dir=`cat $SMALLTALK_CI_VM | sed 's|\(.*\)/.*|\1|'`/pharo-vm
package_dir_arm="$PROJECT_NAME-$PLATFORM-ARM"
vm_dir_arm=arm-pharo-vm

mkdir -p "$package_dir/image"

cp -r $vm_dir/Pharo.app/ $package_dir/Pharo.app

cp $ci_build_dir/TravisCI.image $package_dir/image/$PROJECT_NAME.image
cp $ci_build_dir/TravisCI.changes $package_dir/image/$PROJECT_NAME.changes
cp $ci_build_dir/*.sources $package_dir/image

cat << EOF > $package_dir/$PROJECT_NAME
#!/bin/bash
\`dirname "\$0"\`/Pharo.app/Contents/MacOS/Pharo \`dirname "\$0"\`/image/$PROJECT_NAME.image
EOF

chmod a+rx $package_dir/$PROJECT_NAME

cat << EOF > $package_dir/README.txt
# Installation and Opening on MacOS 10+
Main issue of opening OpenPonk on macOS 10+ is Gatekeeper protection against executables from unverified sources.
There are two options to overcome it.
First option requires a little more clicking each time opening OpenPonk, but very simple first time setup,
Second option requires much more steps first time opening (or after updating OP), but further opening becomes simple double click.
First option:
First time opening (or after updating OP):
1) Double click Pharo.app
-> "Pharo cannot be opened because the developer cannot be verified"
2) Cancel
3) Right click Pharo.app
4) Open
-> "macOS cannot verify the developer of Pharo"
5) Open
-> Window with file selection opened
6) Find and select file $PROJECT_NAME.image in the image folder
-> "Pharo would like to access files"...
7) OK
-> OpenPonk should open now. If there is a window asking to receive keystrokes, you may Deny it
Opening:
1) Double click Pharo.app
-> Window with file selection opened
2) Find and select file $PROJECT_NAME.image in the image folder
Second option:
First time opening (or after updating OP):
1) Right click the $PROJECT_NAME (Unix executable)
2) Open
-> "macOS cannot verify the developer of $PROJECT_NAME"
3) Open
-> "Pharo cannot be opened because the developer cannot be verified"
4) Cancel
5) Open macOS System Preferences...
6) Security & Privacy
7) Switch to General tab (if not already there)
-> There should be text about "Pharo" or "Pharo.app" being blocked and Open Anyway button next to it.
8) Click on Open Anyway button
-> "macOS cannot verify the developer of Pharo"
9) Open
-> Window with file selection opened
10) Cancel
11) Double click $PROJECT_NAME (Unix executable)
-> "Terminal would like to access files"... That, along with next step, might be skipped if the access is already granted.
12) OK
-> OpenPonk should open now. If there is a window asking to receive keystrokes, you may Deny it
Opening:
1) Double click $PROJECT_NAME (Unix executable)
EOF

cat "ci-scripts/.github/scripts/readmecommon.txt" >> "$package_dir/README.txt"

$vm_dir/Pharo.app/Contents/MacOS/Pharo --headless $package_dir/image/$PROJECT_NAME.image eval --save "OPVersion currentWithRunId: $RUN_ID projectName: '$REPOSITORY_NAME'"

zip -qr $PROJECT_NAME-$PLATFORM-$VERSION.zip $package_dir

# ARM variant
mkdir -p "$vm_dir_arm"
mkdir -p "$package_dir_arm"

wget "https://files.pharo.org/get-files/${PHARO_VERSION}0/pharo-vm-Darwin-arm64-stable.zip"
unzip pharo-vm-Darwin-arm64-stable.zip -d "$vm_dir_arm"
cp -r "$package_dir"/* "$package_dir_arm"
rm -rf "$package_dir_arm/Pharo.app"
cp -r $vm_dir_arm/Pharo.app/ $package_dir_arm/Pharo.app

zip -qr $PROJECT_NAME-$PLATFORM-ARM-$VERSION.zip $package_dir_arm
44 changes: 44 additions & 0 deletions .github/scripts/build-win.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
$ci_build_dir="$home\.smalltalkCI\_builds"

$REPOSITORY_NAME=$Env:REPOSITORY_NAME
$PROJECT_NAME=$Env:PROJECT_NAME
$PLATFORM=$Env:PLATFORM
$VERSION=$Env:VERSION
$RUN_ID=$Env:RUN_ID

$package_dir="$PROJECT_NAME-$PLATFORM"
$vm_file_content=Get-Content $ci_build_dir/vm | Out-String
$vm_dir=(($vm_file_content -replace '/[^/]*$','/pharo-vm') -replace '/c/','C:\') -replace '/','\'

mkdir $package_dir
mkdir $package_dir/image
mkdir $package_dir/Pharo

cp $ci_build_dir/TravisCI.image $package_dir/image/$PROJECT_NAME.image
cp $ci_build_dir/TravisCI.changes $package_dir/image/$PROJECT_NAME.changes
cp $ci_build_dir/*.sources $package_dir/image

cp $vm_dir/*.dll $package_dir/Pharo
cp $vm_dir/Pharo.exe $package_dir/Pharo
cp $vm_dir/PharoConsole.exe $package_dir/Pharo

"@echo off
start `"`" `"%~dp0Pharo\Pharo.exe`" `"%~dp0image\$PROJECT_NAME.image`"" | set-content "$package_dir/$PROJECT_NAME.bat"

". `"`$PSScriptRoot\Pharo\Pharo.exe`" `"`$PSScriptRoot\image\openponk-plugins.image`"" | set-content "$package_dir/$PROJECT_NAME.ps1"

"# Installation and Opening
Make sure you do not put OpenPonk directory in a path with non-ASCII chars (like š,ý,ü etc.), otherwise it would not open.
Open using $PROJECT_NAME.bat.
Opening may take several seconds. If OpenPonk becomes unresponsive almost immediately and keeps increasing memory usage quickly, try opening by right-clicking $PROJECT_NAME.ps1 and `"Run with powershell`"
" | Set-Content "$package_dir/README.txt"

Get-Content -Path "ci-scripts\.github\scripts\readmecommon.txt" | Add-Content -Path "$package_dir/README.txt"

& $vm_dir/PharoConsole.exe -headless $package_dir/image/$PROJECT_NAME.image eval --save "OPVersion currentWithRunId: $RUN_ID projectName: '$REPOSITORY_NAME'"

Compress-Archive -Path $package_dir -DestinationPath "$PROJECT_NAME-$PLATFORM-$VERSION.zip"
3 changes: 3 additions & 0 deletions .github/scripts/postLoad.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PharoLightTheme beCurrent.
Smalltalk at: #OPUmlClassEditorPlugin ifPresent: [ :plugin | plugin withAllSubclasses flatCollectAsSet: #defaultProfiles ].
PolymorphSystemSettings setDesktopLogoWith: OPCoreIcons logo asMorph.
1 change: 1 addition & 0 deletions .github/scripts/preLoad.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Iceberg remoteTypeSelector: #httpsUrl
57 changes: 57 additions & 0 deletions .github/scripts/readmecommon.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Project, Model, Diagram

OpenPonk application is implemented in Pharo programming environment that can be described as a programming OS running in a VirtualBox-like virtual machine.
In the OpenPonk application, you may open multiple OpenPonk windows, each representing an OpenPonk project.
In each OP project, you may have multiple independent models.
Models alone contain elements, their properties and relations and do not have any information about visual representation.
Diagrams are those visual representation. One model can have many diagram representations and these diagrams may only show small part of a model.

When you add new elements, delete them or change their properties, you change not only the current diagram, but also the model used for all the diagrams of the same model.
If you wish to omit (hide) some elements from a diagram, but keep them in the model (and possibly other diagrams), use Hide menu items. To show them again, use Show.

# Saving

There are two independent saving systems. Option 1 is more convenient on a single computer, but not very safe, while option 2 is generally safer and its save file is more portable. You may actually use both options at once.

1) Saving OpenPonk environment:
You may save whole OpenPonk application environment, including open windows, dialog popups, not-yet-properly-saved projects etc. This is very convenient as you save multiple projects at once and everything opens exactly like you saved it. However, if the OpenPonk application glitches and refuses to open, you lose everything that is only saved this way.
It is saved into .image and .changes files inside image directory and these files can become very large and unsuitable for moving to other computers, versioning etc.

How to save this way (2 alternatives):
- In very top toolbar > Pharo > Save (or Save and Quit)
- When attempting to close the OP app window, it asks if you want to save changes. Picking Save does exactly this kind of save.

How to load this kind of save:
- Just open OpenPonk application again

2) Saving a single project:
You may save a single project to an .opp (OpenPonk Project) file, which is a zip file with various json/xml files with project metadata, models, diagrams etc.

How to save this way:
- In OpenPonk project's sub-window > Project > Save Project

How to load this kind of save:
- In very top toolbar > OpenPonk > Open Project...

# Settings

OpenPonk settings are available after opening Project window, then
OpenPonk > Settings

# Dragging/Moving elements

Whenever you are dragging elements of a diagram, they attempt to snap to center or sides of other nearby elements.
To disable snapping for the current drag, hold Alt key when dragging.
To permanently disable it, go to OpenPonk settings and set "Shapes checked for drag snapping" to 0

# Keyboard shortcuts

All keyboard shortcuts only work inside drawing area and there are currently no shortcuts for project itself.
Activating keyboard shortcuts sometimes needs clicking into canvas area once again, even if it is responding to mouse already.

Scroll diagram: arrows
Zoom in/out: +/-
Delete element: Delete (with confirmation dialog) or Ctrl+Delete (without confirmation)
Hide element: Ctrl+H
Save OpenPonk environment (option 1 save): Ctrl+Shift+S

79 changes: 79 additions & 0 deletions .github/scripts/save-stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

set -euxo pipefail

package_dir="$PROJECT_NAME-$PLATFORM"

mkdir $package_dir

unzip -q $PROJECT_NAME-$PLATFORM-$VERSION.zip

"$package_dir/pharo/bin/pharo" --headless $package_dir/image/$PROJECT_NAME.image eval "
| getResponse getContents downloads text timestamp filename putResponse |
getResponse := ZnClient new
url:
'https://api.github.com/repos/openponk/$REPOSITORY_NAME/releases/tags/nightly';
accept: ZnMimeType applicationJson;
setBearerAuthentication: '$GITHUB_TOKEN';
get;
response.
getContents := STONJSON fromString: getResponse entity contents.
(getResponse status >= 300 or: [
(getContents includesKey: #assets) not ]) ifTrue: [
self error: (String streamContents: [ :s |
s << 'Get response status ' << getResponse status asString << '.'.
getResponse status == 404 ifTrue: [
s
<<
' If this is the first build of this repository, manually create pre-release named "nightly" first and create branch named dls (possibly with no files). This is whole body of response: '
<< getResponse entity contents ] ]) ].
downloads := (getContents at: #assets) sumNumbers: [ :each |
each at: #download_count ].
downloads isZero ifTrue: [
^ 'No downloads of last nightly build - nothing to upload' ].
text := String streamContents: [ :s |
s << 'name,created_at,download_count'.
s lf.
(getContents at: #assets) do: [ :each |
s << (each at: #name) asString << ','
<< (each at: #created_at) asString << ','
<< (each at: #download_count) asString.
s lf ] ].
timestamp := DateAndTime now asString.
filename := ((timestamp first: 19) copyReplaceAll: ':' with: '')
, '.csv'.
putResponse := ZnClient new
url:
'https://api.github.com/repos/openponk/$REPOSITORY_NAME/contents/'
, filename;
accept: ZnMimeType applicationJson;
setBearerAuthentication: '$GITHUB_TOKEN';
entity: (ZnEntity
with: '{
\"content\":\"' , text asByteArray base64Encoded , '\",
\"message\":\"' , timestamp , '\",
\"branch\":\"dls\"
}'
type: ZnMimeType applicationJson);
put;
response.
(putResponse status >= 300) ifTrue: [
self error: (String streamContents: [ :s |
s << 'Put response status ' << putResponse status asString << '.'.
putResponse status == 404 ifTrue: [
s
<<
' If this is the first build of this repository, manually create branch named dls (possibly with no files). This is whole body of response: '
<< putResponse entity contents ] ]) ].
^ 'Uploaded ' , downloads asString , ' download count'
"
43 changes: 43 additions & 0 deletions .github/workflows/ci-scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI-Scripts

on:
push:
branches:
- 'master'
schedule:
- cron: "42 23 31 12 *"

jobs:

create-dependent-matrix:
runs-on: ubuntu-latest
name: 'Find dependent repositories'
if: ${{ github.event_name == 'push' || contains(github.event.inputs.build-dependent || false, 'true') }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Check list of repositories exists
id: check-file
run: test -f ./.github/dependent-repositories.txt || exit 1
- name: Create dependent build matrix
id: set-matrix
run: echo "::set-output name=matrix::`cat ./.github/dependent-repositories.txt | tr -d " \t\n\r"`"

build-dependent:
needs: [create-dependent-matrix]
runs-on: ubuntu-latest
name: 'Build dependent'
if: ${{ contains(needs.create-dependent-matrix.outputs.matrix, '/') }}
strategy:
matrix: ${{fromJson(needs.create-dependent-matrix.outputs.matrix)}}
steps:
- name: Start ${{ matrix.repository }} build
uses: benc-uk/[email protected]
with:
workflow: Nightly
repo: ${{ matrix.repository }}
ref: ${{ matrix.branch }}
token: ${{ secrets.WORKFLOW_ACCESS_TOKEN }}
inputs: '{ "build-dependent": "${{ matrix.build-dependent }}" }'
Loading

0 comments on commit cd510dc

Please sign in to comment.