diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..e117909 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# `.gitattributes` reclassify `.st` files as iec-st: +** linguist-vendored +# *.ppjs linguist-language=ST diff --git a/.github/workflows/build-library.yml b/.github/workflows/build-library.yml new file mode 100644 index 0000000..7975d79 --- /dev/null +++ b/.github/workflows/build-library.yml @@ -0,0 +1,18 @@ +on: push + +jobs: + build-apax-lib: + uses: simatic-ax/actions/.github/workflows/apax-build.yml@stable + secrets: + APAX_TOKEN: ${{ secrets.APAX_TOKEN }} + with: + ACTIONS_REF: stable + LOGIN_SIMATIC_AX: true + + test-apax-lib: + needs: build-apax-lib + uses: simatic-ax/actions/.github/workflows/apax-build-test.yml@stable + secrets: + APAX_TOKEN: ${{ secrets.APAX_TOKEN }} + with: + LOGIN_SIMATIC_AX: true \ No newline at end of file diff --git a/.github/workflows/github-action-release.yml b/.github/workflows/github-action-release.yml deleted file mode 100644 index 029abd3..0000000 --- a/.github/workflows/github-action-release.yml +++ /dev/null @@ -1,178 +0,0 @@ -name: release-package -on: - push: - branches: - - release - -env: - PROJECT_NAME: collections - SCOPE: simatic-ax - ACTIONS_REPO: simatic-ax/actions - ACTIONS_LOCAL: ./actions - VERSIONING_TOOL_REPO: simatic-ax/simatic_versioning - -jobs: - versioning: - name: "Bump the version of the package according to the conventional commit" - runs-on: ubuntu-latest - steps: - - name: "Clone the library repository" - uses: actions/checkout@v3 - - name: "Clone repository for CI workflows" - uses: actions/checkout@v3 - with: - repository: ${{ env.ACTIONS_REPO }} - token: ${{ secrets.CI_KIT_TOKEN }} - path: ./actions - - name: "Get the latest version of the package" - run: | - echo "@simatic-ax:registry=https://npm.pkg.github.com/" >> .npmrc - echo "//npm.pkg.github.com/:_authToken=${{ secrets.CI_KIT_TOKEN }}" >> .npmrc - echo "always-auth = true" >> .npmrc - cat .npmrc - echo "VERSION=$(npm show @${{ env.SCOPE }}/${{ env.PROJECT_NAME }} version --registry=https://npm.pkg.github.com --scope=${{ env.SCOPE }})" >> $GITHUB_ENV - echo $VERSION - - name: "Check contents of actions folder" - run: tree -d ./actions - - name: "Install apax and dependencies" - uses: ./actions/.github/actions/setup-apax-runner - with: - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Get latest simatic-versioning executable" - uses: dsaltares/fetch-gh-release-asset@master - with: - repo: ${{ env.VERSIONING_TOOL_REPO }} - file: "conventional-commit" - token: ${{ secrets.CI_KIT_TOKEN }} - - - id: bump - name: "Bump version" - run: | - apax version ${{ env.VERSION }} - sudo chmod +x ./conventional-commit - ./conventional-commit -c "${{ github.event.head_commit.message }}" -v "${{ env.VERSION }}" >> .version - cat .version - - - name: "Upload version" - uses: actions/upload-artifact@v3 - with: - name: version - path: .version - - build: - name: "Build apax library" - runs-on: ubuntu-latest - needs: versioning - steps: - - name: "Clone the library repository" - uses: actions/checkout@v3 - - - name: "Clone repository for CI workflows" - uses: actions/checkout@v3 - with: - repository: ${{ env.ACTIONS_REPO }} - token: ${{ secrets.CI_KIT_TOKEN }} - path: ./actions - - - name: "Install apax and dependencies" - uses: ./actions/.github/actions/setup-apax-runner - with: - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Login to the private repo" - run: | - apax login \ - --registry "https://npm.pkg.github.com" \ - --password ${{ secrets.CI_KIT_TOKEN }} - - - name: "Build apax library" - uses: ./actions/.github/actions/apax-build - with: - library-directory: ${{ github.workspace }} - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Upload artifact" - uses: actions/upload-artifact@v3 - with: - name: library-artifact - path: bin/ - - test: - name: "Test apax library" - runs-on: ubuntu-latest - needs: build - steps: - - name: "Clone the library repository" - uses: actions/checkout@v3 - - - name: "Clone repository for CI workflows" - uses: actions/checkout@v3 - with: - repository: simatic-ax/actions - token: ${{ secrets.CI_KIT_TOKEN }} - path: ./actions - - - name: "Install apax and dependencies" - uses: ./actions/.github/actions/setup-apax-runner - with: - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Login to the private repo" - run: | - apax login \ - --registry "https://npm.pkg.github.com" \ - --password ${{ secrets.CI_KIT_TOKEN }} - - - name: "Build apax library" - uses: ./actions/.github/actions/apax-test - with: - library-directory: ${{ github.workspace }} - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Test apax package" - run: apax test - - release: - name: "Release binary" - runs-on: ubuntu-latest - needs: test - steps: - - name: "Clone the library repository" - uses: actions/checkout@v3 - - - name: "Clone repository for CI workflows" - uses: actions/checkout@v3 - with: - repository: simatic-ax/actions - token: ${{ secrets.CI_KIT_TOKEN }} - path: ./actions - - - name: "Install apax and dependencies" - uses: ./actions/.github/actions/setup-apax-runner - with: - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Download artifact" - uses: actions/download-artifact@v3 - with: - name: library-artifact - - - name: "Login to the private repo" - run: | - apax login \ - --registry "https://npm.pkg.github.com" \ - --password ${{ secrets.CI_KIT_TOKEN }} - - - name: "Download artifact" - uses: actions/download-artifact@v3 - with: - name: version - - - name: "Pack and publish the library" - run: | - cat .version - apax version "$(cat .version)" - apax pack 2>.package.err 1>.signature - PACKAGE="$(grep -oP '(?<=\").+.apax\.tgz(?=\")' .package.err)" - apax publish --package $PACKAGE --registry https://npm.pkg.github.com diff --git a/.github/workflows/github-action-test-apax.yml b/.github/workflows/github-action-test-apax.yml deleted file mode 100644 index 1814da0..0000000 --- a/.github/workflows/github-action-test-apax.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: test-apax -on: - push: - branches: - - '*' - - '!release' -env: - ACTIONS_REPO: simatic-ax/actions - VERSIONING_TOOL_REPO: simatic-ax/simatic_versioning - -jobs: - build: - name: "Build apax library" - runs-on: ubuntu-latest - - steps: - - name: "Clone the library repository" - uses: actions/checkout@v3 - - - name: "Clone repository for CI workflows" - uses: actions/checkout@v3 - with: - repository: ${{ env.ACTIONS_REPO }} - token: ${{ secrets.CI_KIT_TOKEN }} - path: actions - - - name: "Check contents of actions folder" - run: tree -d ./actions - - name: "Install apax and dependencies" - uses: ./actions/.github/actions/setup-apax-runner - with: - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Login to the private repo" - run: | - apax login \ - --registry "https://npm.pkg.github.com" \ - --password ${{ secrets.CI_KIT_TOKEN }} - - - name: "Build apax library" - uses: ./actions/.github/actions/apax-build - with: - library-directory: ${{ github.workspace }} - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Upload artifact" - uses: actions/upload-artifact@v3 - with: - name: library-artifact - path: bin/ - - test: - name: "Test apax library" - runs-on: ubuntu-latest - needs: build - steps: - - name: "Clone the library repository" - uses: actions/checkout@v3 - - - name: "Clone repository for CI workflows" - uses: actions/checkout@v3 - with: - repository: ${{ env.ACTIONS_REPO }} - token: ${{ secrets.CI_KIT_TOKEN }} - path: actions - - name: "Install apax and dependencies" - uses: ./actions/.github/actions/setup-apax-runner - with: - apax-access-token: ${{ secrets.APAX_TOKEN }} - - - name: "Login to the private repo" - run: | - apax login \ - --registry "https://npm.pkg.github.com" \ - --password ${{ secrets.CI_KIT_TOKEN }} - - - name: "Install workspace dependencies and test" - uses: ./actions/.github/actions/apax-test - with: - apax-access-token: ${{ secrets.APAX_TOKEN }} diff --git a/.github/workflows/lint-repo.yml b/.github/workflows/lint-repo.yml new file mode 100644 index 0000000..9863aa7 --- /dev/null +++ b/.github/workflows/lint-repo.yml @@ -0,0 +1,4 @@ +on: push +jobs: + lint-repo-and-markdown: + uses: simatic-ax/actions/.github/workflows/check-repository.yml@stable diff --git a/.github/workflows/release-library.yml b/.github/workflows/release-library.yml new file mode 100644 index 0000000..c516032 --- /dev/null +++ b/.github/workflows/release-library.yml @@ -0,0 +1,15 @@ +on: + push: + # Pattern matched against refs/tags + tags: + - '*' + +jobs: + release-apax-lib: + uses: simatic-ax/actions/.github/workflows/apax-publish.yml@stable + secrets: + APAX_TOKEN: ${{ secrets.APAX_TOKEN }} + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} + + with: + VERSION: ${{ github.ref_name }} diff --git a/.gitignore b/.gitignore index f33b24d..f0cef51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ .apax/ .env/ [Bb]in/ +[Oo]bj/ [Ll]ibrary/ [Tt]est[Rr]esult*/ *.tgz *.tracerec.json -obj \ No newline at end of file diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..95479c5 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,11 @@ +# markdownlint YAML configuration +--- + +# Default state for all rules +default: true + +# ignored rules +line-length: false +no-inline-html: false +first-line-h1: false +no-emphasis-as-header: false \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..e86a9e5 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,4 @@ +# These owners will be the default owners for everything in the repo. +# Unless a later match takes precedence, the listed user will be +# requested for review when someone opens a pull request. +* @sjuergen @BeckerStS \ No newline at end of file diff --git a/LIBRARY.md b/LIBRARY.md index 52a6a63..f601397 100644 --- a/LIBRARY.md +++ b/LIBRARY.md @@ -1,2 +1 @@ # Creating a library project - diff --git a/LICENSE.md b/LICENSE.md index 63d21d5..dce28a1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -10,9 +10,7 @@ Siemens AG and/or a subsidiary of Siemens AG ("Siemens") provides You royalty-fr Siemens provides products and solutions with industrial security functions that support the secure operation of plants, systems, machines and networks. -In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. - -Siemens' products and solutions constitute one element of such a concept. +In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens' products and solutions constitute one element of such a concept. Customers are responsible for preventing unauthorized access to their plants, systems, machines and networks. Such systems, machines and components should only be connected to an enterprise network or the internet if and to the extent such a connection is necessary and only when appropriate security measures (e.g. firewalls and/or network segmentation) are in place. For additional information on industrial security measures that may be implemented, please visit @@ -22,19 +20,23 @@ For additional information on industrial security measures that may be implement You shall comply with all applicable sanctions, embargoes and (re-)export control regulations, and, in any event, with those of the European Union and the United States of America (collectively "Export Regulations"). In particular, the information, software and documentation provided by Siemens (collectively "Licensed Material") shall not be used, accessed or transferred, unless permitted by the Export Regulations or respective governmental licenses or approvals, (i) in or to any location prohibited by or subject to comprehensive sanctions (currently Russia, Cuba, Iran, North Korea, Syria, and the Crimea region of Ukraine, Donetsk and Luhansk regions of Ukraine) or license requirements according to the Export Regulations; (ii) by or to any individual or entity designated on a sanctioned party list of the Export Regulations; (iii) for any purpose prohibited by the Export Regulations (e.g. use in connection with armaments, nuclear technology or weapons); or (iv) to upload any content unless it is noncontrolled (e .g. in the EU: AL = N; in the U.S.: ECCN = N or EAR99). If required to enable authorities or Siemens to conduct export control checks, You, upon request by Siemens, shall promptly provide Siemens with all information pertaining to You, the intended use and the location of use of the Licensed Material. Siemens shall not be obligated to fulfill this Agreement if such fulfillment is prevented by any impediments arising out of national or international foreign trade or customs requirements or any embargoes or other sanctions. -**2. Open Source License for Software in source code and generated source code** +**2. Open Source License for Software provided in source code and the generated source code** -In case the Software contains or generates source code the following open source license shall apply for such source code: +In case the Software contains or generates source code the following open source license (Open license terms) shall apply for such source code: -MIT License + MIT License + + Copyright 2022 Siemens AG -Copyright 2022 Siemens AG + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +To the extent there is a conflict between this terms and conditions and the Open License Terms, the Open License Terms shall prevail over this terms and conditions with regard to source code. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +You acknowledge and agree that Siemens provides no warranties, express or implied, for the open source software itself. Siemens shall have no liability nor shall Siemens provide any indemnification whatsoever in respect of Your distribution or modification of the open source software. **3. Software provided in object code** @@ -52,10 +54,10 @@ Siemens shall make available to You, at Your request, the Open Source Software s The Software may, in addition to Open Source Software, contain other licensed software, i.e. software which was not developed by Siemens itself, but which Siemens has obtained from third parties, e.g. Microsoft Ireland Operations Ltd, under a license. If You shall receive in such case the conditions of the respective licensor of the licensed software in the Readme_OSS file, these shall apply to the liability of the licensor in relation to You. In terms of the liability of Siemens to You, these Royalty-Free Siemens Software Conditions shall apply in each case. -Royalty-Free Software License Version 1.0 – 11.04.2022 - **3.3 Disclaimer of liability** Siemens shall not assume any liability, for any legal reason whatsoever, including, without limitation, liability for the usability, availability, completeness and freedom from defects of the Software as well as for the Licensed Material and any damage caused thereby. This shall not apply in cases of mandatory liability, for example product liability law or in cases of intent, gross negligence, or culpable loss of life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for damages arising from a breach of material contractual obligations shall however be limited to the foreseeable damage typical of the type of agreement, unless liability arises from intent or gross negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions do not imply any change in the burden of proof to Your detriment. You shall indemnify Siemens against existing or future claims of third parties in this connection except where Siemens is mandatorily liable. By using the Software and the Licensed Material, You acknowledge that Siemens cannot be held liable for any damage beyond the liability provisions described. + +Royalty-Free Software License Version 1.1 – 30.09.2022 diff --git a/README.md b/README.md index 341c1d7..8149519 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,24 @@ # Simatic.AX.Collections -## Version -Version 0.2.0 see [change log](changelog.md) +This collection library contains some classes for list handling of types of IListItem. Unfortunately the ST implementation does not support any generic data types and also no dynamic memory allocation. Therefore this example library has much space for improvement and it is open for discussion with other users. -This collection library contains some useful classes for list handling of types of IListItem. The Advantage of the concept is, that you don't need to use arrays with fixed size and you can mix the types as long as they're of type IListItem. +The actual implementation is based on a linked list item (IListItem) where you need to create for each item a instance (which also can be stored in an array) +The Advantage of the concept is, that you don't need to use arrays with fixed size and you can mix the types as long as they're of type IListItem. -> Important: By inserting, adding, writing some items NO copy of the object will be created. + +> Important: By inserting, adding, writing some items NO copy of the object will be created. You need to manage the list items by yourself. ## Install this package Enter: + ```cli apax add @simatic-ax/collections ``` -## Namespace +## Namespace -``` +```iec-st Simatic.Ax.Collections; ``` @@ -24,7 +26,7 @@ Simatic.Ax.Collections; ## Linked List -### Add() : IListItem Method +### LinkedList.Add() : IListItem Method Add a new object IListItem to the end of the list @@ -43,7 +45,7 @@ METHOD PUBLIC FINAL Add : IListItem END_METHOD ``` -### Remove() : BOOL Method +### LinkedList.Remove() : BOOL Method Remove a IListItem from the list. @@ -60,13 +62,13 @@ END_METHOD |Return Value |Bool |Removing item was successful | |item |IListItem |Reference to item to be removed | -## Queue +## Fifo Represents a first-in, first-out (FIFO) collection of IListItem. -### Enqueue(item : IListItem) : IListItem Method +### Fifo.Enqueue(item : IListItem) : IListItem Method -```iec-st +```iec-st METHOD Enqueue : IListItem VAR_INPUT item : IListItem; @@ -79,7 +81,7 @@ END_METHOD |Return Value |IListItem |Reference to the enqueued item | |item |IListItem |Item to be inserted | -### Dequeue() : IListItem Method +### Fifo.Dequeue() : IListItem Method ```iec-st METHOD Dequeue : IListItem @@ -90,7 +92,7 @@ END_METHOD |-|-|-| |Return Value | IListItem | Return and remove the oldest element in the list | -### Count() INT; +### Fifo.Count() INT ```iec-st METHOD PUBLIC Count : INT @@ -105,9 +107,9 @@ END_METHOD Represents a simple last-in-first-out (LIFO) collection of IListItem. -### Push(item : IListItem) : IListItem Method +### Stack.Push(item : IListItem) : IListItem Method -```iec-st +```iec-st METHOD Push : IListItem VAR_INPUT item : IListItem; @@ -120,7 +122,7 @@ END_METHOD |Return Value |IListItem |Reference to the pushed item | |item |IListItem |Item to be inserted | -### Pop() : IListItem Method +### Stack.Pop() : IListItem Method ```iec-st METHOD Pop : IListItem @@ -131,7 +133,7 @@ END_METHOD |-|-|-| |Return Value | IListItem | Return and remove the newest element in the list | -### Peek() : IListItem Method +### Stack.Peek() : IListItem Method ```iec-st METHOD Peek : IListItem @@ -142,7 +144,7 @@ END_METHOD |-|-|-| |Return Value | IListItem | Return the newest element in the list (without removing) | -### Count() INT; +### Stack.Count() : INT ```iec-st METHOD PUBLIC Count : INT @@ -157,6 +159,15 @@ END_METHOD Thanks for your interest in contributing. Anybody is free to report bugs, unclear documentation, and other problems regarding this repository in the Issues section or, even better, is free to propose any changes to this repository using Merge Requests. +### Markdownlint-cli + +This workspace will be checked by the [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) (there is also documented ho to install the tool) tool in the CI workflow automatically. +To avoid, that the CI workflow fails because of the markdown linter, you can check all markdown files locally by running the markdownlint with: + +```sh +markdownlint **/*.md --fix +``` + ## License and Legal information Please read the [Legal information](LICENSE.md) diff --git a/changelog.md b/changelog.md deleted file mode 100644 index bfb54ce..0000000 --- a/changelog.md +++ /dev/null @@ -1,9 +0,0 @@ -# Changelog - -## January 2022-02-01 - -### 0.2.0 -- **breaking change** rename Stack to LIFO -- **breaking change** rename FIFO method `Read` to `Dequeue` and `Write` to `Enqueue` -- update Read.me - \ No newline at end of file diff --git a/repolinter.json b/repolinter.json new file mode 100644 index 0000000..f662361 --- /dev/null +++ b/repolinter.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://raw.githubusercontent.com/todogroup/repolinter/master/rulesets/schema.json", + "version": 2, + "axioms": { + "linguist": "language", + "licensee": "license", + "packagers": "packager" + }, + "rules": { + "license-file-exists": { + "level": "off", + "rule": { + "type": "file-existence", + "options": { + "globsAny": ["LICENSE*", "COPYING*"], + "nocase": true + } + } + } + } +} \ No newline at end of file diff --git a/src/Queue/Queue.st b/src/Queue/Fifo.st similarity index 100% rename from src/Queue/Queue.st rename to src/Queue/Fifo.st diff --git a/src/Queue/IQueue.st b/src/Queue/IFifo.st similarity index 94% rename from src/Queue/IQueue.st rename to src/Queue/IFifo.st index bdc5ea3..41e1691 100644 --- a/src/Queue/IQueue.st +++ b/src/Queue/IFifo.st @@ -1,6 +1,6 @@ NAMESPACE Simatic.Ax.Collections - INTERFACE IQueue + INTERFACE IFifo METHOD Enqueue : IListItem VAR_INPUT item : IListItem;