Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: ARCH autodetect #2

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/workflows/act-test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
on: push

jobs:
act_test:
name: ACT Test
linux_x64_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run ACT (test)
env:
ARCH: "x86-64"
run: |
set -o pipefail --
curl -sSf https://raw.githubusercontent.com/sine-fdn/act/main/act.sh?token=${{secrets.ACT_TOKEN}} | \
bash -s -- \
-e "https://api.ileap.sine.dev" \
-u ${{secrets.ACT_USER}} \
-p ${{secrets.ACT_PASSWORD}} \
cat act.sh \
| bash -s -- \
-e "https://api.ileap.sine.dev" \
-u ${{secrets.ACT_USER}} \
-p ${{secrets.ACT_PASSWORD}}
mac_amd64_test:
runs-on: max-latest
steps:
- uses: actions/checkout@v2
- name: Run ACT (test)
run: |
cat act.sh \
| bash -s -- \
-e "https://api.ileap.sine.dev" \
-u ${{secrets.ACT_USER}} \
-p ${{secrets.ACT_PASSWORD}}
67 changes: 46 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,81 @@
# ACT (beta)

ACT (Automated Conformance Testing) tests your software solution against the [PACT Technical
Specifications](https://wbcsd.github.io/data-exchange-protocol/v2/) as part of your CI/CD pipeline.
Specifications](https://wbcsd.github.io/data-exchange-protocol/v2/).

ACT performs the tests included in [PACT's checklist](https://wbcsd.github.io/pact-conformance-testing/checklist.html), ensuring that your software is ready for bilateral conformance testing. Having ACT in your CI/CD pipeline saves you time and money, by preventing you from engaging in premature manual bilateral testing.
For this, ACT performs the tests included in [PACT's checklist](https://wbcsd.github.io/pact-conformance-testing/checklist.html), ensuring that your software is ready for bilateral conformance testing.

# Usage
By integrating ACT into your CI/CD pipeline and development processes, you can streamline the PACT Tech Specs implementation and conformance process in general.

## CLI

To use act in the CLI, simply copy the following command, replacing `<url>`, `<user>`, and `<password>` with the URL of your API and the Basic Auth credentials (user and password).
> [!NOTE]
> ACT is still under development. This means that the tool is not yet fully stable and may not cover all
> the requirements of the PACT Technical Specifications or that its tests may differ from the Tech Specs.
>
> If you encounter any issues or difficulties, give us [feedback](#contact), open an issue on the [ACT GitHub repository](https://github.com/sine-fdn/act/issues).

```
curl -sSf https://raw.githubusercontent.com/sine-fdn/act/main/act.sh | bash -s -- -e "<url>" -u "<user>" -p "<password>"
```

### Architecture
# Usage

To specify the architecture of the binary you want to run, pass the environment variable `ARCH` with either the value `"arm64"` or the value `"x86-64"`. Defaults to `"arm64"`.
You can use ACT in the CLI or in a GitHub workflow.

> Note: Any other value is considered invalid and the default will be used.
All you need to do is to adapt below commands to your environment and run them in your terminal or in your GitHub workflow:

### Skip HTTP-only tests
```sh
curl -sSf https://raw.githubusercontent.com/sine-fdn/act/main/act.sh |\
bash -s -- -e "<url>" -u "<user>" -p "<password>" --skip-http-check
```

If you're testing against a local server, test cases 014, 015, and 016 will always fail, since these actions are made available through HTTP (non-HTTPS). We recommend skipping these tests by adding the argument `--skip-http-check`.
(i.e. `<user>`, `<password>` etc. are placeholders for your actual client credentials)

**Example with SINE's iLEAP demo API**
```
ARCH="arm64" curl -sSf https://raw.githubusercontent.com/sine-fdn/act/main/act.sh | bash -s -- -e "https://api.ileap.sine.dev" -u "hello" -p "pathfinder" --skip-http-check

Example usage with SINE's iLEAP demo API
```sh
curl -sSf https://raw.githubusercontent.com/sine-fdn/act/main/act.sh |\
bash -s -- -e "https://api.ileap.sine.dev" -u "hello" -p "pathfinder" \
--skip-http-check
```


## GitHub Workflow

Adding ACT to your CI/CD pipeline with GitHub is as simple as including the following job in your GitHub workflow, replacing `<url>`, `<user>`, and `<password>` with the URL of your API and the Basic Auth credentials (user and password).

```
```TOML
act_test:
name: ACT Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run ACT (test)
env:
ARCH: "x86-64"
run: |
set -o pipefail
curl -sSf https://raw.githubusercontent.com/sine-fdn/act/main/act.sh | \
bash -s -- \
-e `<url>` \
-u `<user>` \
-p `<password>` \
--skip-http-check
```

The Basic Auth credentials can (and should) be passed in through repository secrets (e.g., `${{secrets.ACT_USER}}` and `${{secrets.ACT_PASSWORD}}`).

In case you're testing against your development build, you need to have it run in parallel. In that case, include also the flag `--skip-http-check`.
### Security Considerations

If you intend to use this action to test live or otherwise production-like systems, you should

1. make sure that credentials are passed in as secrets
(e.g., `${{secrets.ACT_USER}}` and `${{secrets.ACT_PASSWORD}}`)
2. remove the `--skip-http-check` flag above


## Limitations

> [!IMPORTANT]
>
> There are builds ready for ARM64 and x86_64 architectures and the `ubuntu-latest` runner only.
> If you need support for a different architecture or runner, please let us know.


# Contact

For any questions, feedback, or issues, please contact us at [[email protected]]([email protected]).
35 changes: 29 additions & 6 deletions act.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
#!/bin/bash

case $ARCH in
arm64 | x86-64)
echo "Downloading $ARCH binary."
#
# What this script does:
# 1. find out the architecture of the machine
# 2. download the conformance binary for the target architecture
# 3. make the binary executable and executes is
#

set -xeuo pipefail

####
# Step 1: Find out the architecture of the machine or default to `arm64`
####

arch=$(uname -m)

case ${arch} in
arm64 | x86_64)
echo "Downloading ${arch} binary."
;;
*)
echo "No architecture specified. Defaulting to arm64."
ARCH="arm64"
echo "The architecture specified is not supported, yet."
exit 5
;;
esac


####
# Step 2: Download the conformance binary for the target architecture
####
conformance_bin=$(mktemp)
trap "rm ${conformance_bin}" EXIT
curl -o ${conformance_bin} "https://actbin.blob.core.windows.net/act-bin/conformance_${arch}"

curl -o ${conformance_bin} "https://actbin.blob.core.windows.net/act-bin/conformance_$ARCH"

####
# Step 3: Make the binary executable and execute it
####
chmod +x ${conformance_bin}
exec ${conformance_bin} "$@"
Loading