Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
30ee4f7
WIP. Added SSH debug step.
nseam Mar 5, 2025
cef7037
Adds vscode-github-actions extension
kenorb Mar 10, 2025
22a79ea
Update molecule workflow to enable debug mode conditionally on failure
kenorb Mar 11, 2025
f0b5218
Removes meta/requirements.txt [no-ci]
kenorb Mar 16, 2025
f17b975
Adds Pipfile and lock file [no-ci]
kenorb Mar 16, 2025
5d07ed3
Updates requirements file [no-ci]
kenorb Mar 16, 2025
4ce0f15
Removes redundant requirements files
kenorb Mar 16, 2025
e13a7a6
Updates requirements.txt
kenorb Mar 16, 2025
865c5fe
Updates Pipfile.lock [no-ci]
kenorb Mar 16, 2025
646f3d2
Adds .markdownlint.yaml
kenorb Mar 16, 2025
f9195ed
Ignores *.html files
kenorb Mar 16, 2025
b9fe519
Corrects copilot-instructions.md
kenorb Mar 16, 2025
43cd798
Updates devcontainer.json
kenorb Mar 16, 2025
9d2e3b7
Updates pre-commit/action to v3.0.1
kenorb Mar 17, 2025
4e5bb47
Improves molecule test report
kenorb Mar 17, 2025
edf8ee8
Adds paths-ignore for molecule workflow
kenorb Mar 17, 2025
1fe86e4
Improves molecule provisioner config options
kenorb Mar 17, 2025
c2cff72
Adds code-review.prompt.md [no-ci]
kenorb Mar 17, 2025
fd81463
Increases timeout to 120
kenorb Mar 17, 2025
4f11b5a
Sets metatrader to v1.0.1 version
kenorb Mar 17, 2025
c34606c
Sets oneline as default Ansible screen output [no-ci]
kenorb Mar 17, 2025
bd42334
Almost complete Cygwin support. Committing before merging dev-mt-repo…
nseam Mar 19, 2025
347fcef
Merge branch 'dev-mt-report-parsing' of https://github.com/nseam/ansi…
nseam Mar 19, 2025
f49a898
Cygwin and Unix, unified support for MT runner.
nseam Mar 24, 2025
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
3 changes: 2 additions & 1 deletion .ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ bin_ansible_callbacks = True
# Leave the 'cows' alone!
nocows = 1
# Use the YAML callback plugin.
stdout_callback = yaml
stdout_callback = default
callback_result_format = yaml

[diff]
# Always print diff when running (same as always running with -D/--diff).
Expand Down
12 changes: 7 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@
"customizations": {
"vscode": {
"extensions": [
"vscodevim.vim",
"DavidAnson.vscode-markdownlint",
"GitHub.copilot-chat",
"GitHub.copilot",
"GitHub.copilot-chat",
"github.vscode-github-actions",
"ms-python.python",
"sourcery.sourcery"
"sourcery.sourcery",
"vscodevim.vim"
],
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
// "ghcr.io/maks1ms/devcontainers-features/wine:0": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers-extra/features/pipx-package:1": {},
"ghcr.io/devcontainers-extra/features/pipx-package:1": {},
"ghcr.io/guiyomh/features/vim:0": {},
"ghcr.io/jungaretti/features/ripgrep:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
Expand All @@ -36,7 +37,8 @@
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"name": "ansible-role-mt-runner",
"postCreateCommand": "pip install -r .devcontainer/requirements.txt",
// Install dependencies and pre-commit hooks.
"postCreateCommand": "pip install -r .devcontainer/requirements.txt && pre-commit install",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
5 changes: 5 additions & 0 deletions .devcontainer/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Python's requirements
# Usage: pip install -r requirements.txt
ansible
ansible-lint
docker>=7.1
molecule
molecule-docker
pipenv
pre-commit
requests==2.31.0
76 changes: 76 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copilot Instructions for ansible-role-mt-runner

You are expected to be an expert in:

- Ansible
- Python
- Jinja2
- Molecule
- Linux (Alpine, Debian/Ubuntu, Nix)
- YAML

## Code Standards

- Avoid writing trailing whitespace
- Follow PEP 8 for Python.
- Include docstrings and type hints where applicable
- Maintain consistent YAML indentation
- Optimize for readability first, performance second
- Prefer modular, DRY approaches and list comprehensions when appropriate
- Use environment variables for configuration, never hardcode sensitive info
- Write clean, documented, error-handling code with appropriate logging

## General Approach

- Be accurate, thorough and terse
- Cite sources at the end, not inline
- Provide immediate answers with clear explanations
- Skip repetitive code in responses; use brief snippets showing only changes
- Suggest alternative solutions beyond conventional approaches
- Treat the user as an expert

## Ansible Guidelines

- Ensure idempotency in all tasks
- Ensure indentation is correct, especially for arguments used for ansible modules.
- Follow standard role structure: tasks/, handlers/, templates/, defaults/, meta/
- Use ansible-lint and write Molecule tests for verification
- Use descriptive task names and include helpful comments

## YAML Guidelines

Ensure the following rules are strictly followed:

- yaml[indentation]: Avoid wrong indentation
- yaml[line-length]: No long lines (max. 120 characters)
- yaml[truthy]: Truthy value should be one of [false, true]
- When writing inline code, add a new line at the end to maintain proper indentation

## Project Specifics

This role installs and runs trading platform with distribution-specific approaches:

- **Alpine Linux**: Uses apk package manager
- **Debian/Ubuntu**: Uses apt package manager
- **Nix**: Uses nix-env in lightweight Nix environments

Notes:

- Project utilizes Codespaces with config file at .devcontainer/devcontainer.json
and requirements at .devcontainer/requirements.txt
- GitHub Actions are used to validate the code by running
pre-commit checks (see .pre-commit-config.yaml file) and Molecule (molecule/).
- Service management uses supervisord across platforms.
- Formatting rules are defined in .yamllint (YAML) and .markdownlint.yaml (Markdown) files.

### Key Variables

Variables are defined in defaults/main.yml and vars/main.yml files.

Notes:

- On variable changes, update main.yml and README.md files accordingly.

### Testing Approach

- Use Molecule with Docker driver
72 changes: 72 additions & 0 deletions .github/prompts/code-review.prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Ansible Role Code Review Guidelines

Your goal is to review Ansible role code
to ensure it meets high-quality standards and follows best practices.

## Ensure Code Quality

- Follow PEP 8 for Python.
- Maintain consistent YAML indentation.
- Optimize for readability first, performance second.
- Ensure idempotency in all Ansible tasks.
- Use environment variables for configuration, never hardcode sensitive info.
- Write clean, documented, error-handling code with appropriate logging.

## Check for Linting and Formatting

- Ensure YAML files adhere to [.yamllint](../../.yamllint) rules.
- Ensure Markdown files adhere to [.markdownlint.yaml](../../.markdownlint.yaml) rules.
- Ensure Ansible playbooks and roles pass `ansible-lint`.

## Review Ansible Role Structure

- Follow standard role structure:

- [tasks/](../../tasks/)
- [handlers/](../../handlers/)
- [templates/](../../templates/)
- [defaults/](../../defaults/)
- [meta/](../../meta/)

- Use descriptive task names and include helpful comments.
- Ensure indentation is correct, especially for arguments used for Ansible modules.

## Verify Variables and Defaults

- Ensure variables are defined in
[defaults/main.yml](../../defaults/main.yml) and [vars/main.yml](../../vars/main.yml).
- Update [README.md](../../README.md) with any changes to variables.
- Ensure variables are used consistently across tasks and playbooks.

## Check for Idempotency

- Ensure all tasks are idempotent and do not cause unnecessary changes on repeated runs.

## Review Molecule Tests

- Ensure Molecule scenarios are defined and cover all supported platforms.
- Verify that Molecule tests are comprehensive and validate the role's functionality.
- Check [molecule/](../../molecule/) directory for test configurations.

## Ensure Proper Error Handling

- Write error-handling code with appropriate logging.
- Ensure tasks fail gracefully and provide meaningful error messages.

## Check for Dependencies

- Ensure all dependencies are listed in
[.devcontainer/requirements.txt](../../.devcontainer/requirements.txt) and [requirements.yml](../../requirements.yml).
- Verify that the role does not have any missing dependencies.

## Review GitHub Actions

- Ensure GitHub Actions workflows are correctly configured to run pre-commit checks and Molecule tests.
- Verify that the workflows cover all necessary validation steps.
- Check [.github/workflows/](../) directory for workflow configurations.

## Documentation

- Ensure the [README.md](../../README.md) file is up-to-date
and provides clear instructions for installation, usage, and variables.
- Include any additional documentation as needed for clarity.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
path: ~/.cache/pre-commit
key: pre-commit|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.0
- uses: pre-commit/action@v3.0.1
63 changes: 56 additions & 7 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ name: Molecule
# yamllint disable-line rule:truthy
on:
pull_request:
paths-ignore:
- '**.md'
- '*.yaml'
- Pipfile*
push:
paths-ignore:
- '**.md'
- '*.yaml'
- Pipfile*

jobs:
Test:
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -17,22 +26,62 @@ jobs:
- mt4
- mt5-ea
steps:
- name: Debug with tmate
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tmate debug action is configured to run at the start of every job with 'detached: true', which means debugging will always be enabled. This should be conditional (e.g., only when runner.debug == '1' or on failure) to avoid leaving debug sessions open unnecessarily and potentially exposing the CI environment.

Suggested change
- name: Debug with tmate
- name: Debug with tmate
if: ${{ runner.debug == '1' }}

Copilot uses AI. Check for mistakes.
uses: mxschmitt/action-tmate@v3
with:
detached: true
- uses: actions/checkout@v4
with:
path: "${{ github.repository }}"
path: ${{ github.repository }}
- name: Install required tools
run: |
sudo apt update
sudo apt install -y x11-apps imagemagick
- name: Start background screenshot loop
run: |
cd $GITHUB_WORKSPACE
mkdir -p screenshots
echo "Starting screenshot loop..."
while true; do
sleep 120
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
SCREENSHOT_FILE="screenshots/latest_screenshot.png"

# Take screenshot
DISPLAY=:0 xwd -root -out temp_screenshot.xwd || true
convert temp_screenshot.xwd "$SCREENSHOT_FILE" || true
rm temp_screenshot.xwd || true

if [ -f "$SCREENSHOT_FILE" ]; then
# Commit latest screenshot with amend
git add "$SCREENSHOT_FILE"
git commit --amend -m "Update latest screenshot taken at $TIMESTAMP"
git push --force-with-lease
fi
done &
Comment on lines +40 to +61
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The background screenshot loop has several issues: 1) It uses git operations (add, commit, push) within CI that could fail or cause conflicts. 2) Using --force-with-lease can overwrite other changes. 3) The loop runs indefinitely without proper cleanup. 4) This approach is unconventional for CI debugging. Consider using CI artifacts instead of git commits for screenshots.

Copilot uses AI. Check for mistakes.
- uses: gofrolist/molecule-action@v2
env:
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_STDOUT_CALLBACK: yaml
MT_RUNNER_MT4_LOGIN: ${{ secrets.MT_RUNNER_MT4_LOGIN || '12345' }}
ANSIBLE_STDOUT_CALLBACK: ${{ runner.debug == '1' && 'debug' || 'oneline' }}
MOLECULE_REPORT: molecule-${{ matrix.scenario }}-report.html
MT_RUNNER_MT4_PASSWORD: ${{ secrets.MT_RUNNER_MT4_PASSWORD || 'SETME' }}
MT_RUNNER_MT5_LOGIN: ${{ secrets.MT_RUNNER_MT5_LOGIN || '12345' }}
MT_RUNNER_MT5_PASSWORD: ${{ secrets.MT_RUNNER_MT5_PASSWORD || 'SETME' }}
with:
molecule_args: --scenario-name ${{ matrix.scenario }}
molecule_command: test
molecule_options: --verbose
molecule_working_dir: "${{ github.repository }}"
- if: ${{ failure() }}
molecule_options: ${{ runner.debug == '1' && '--verbose' || '' }}
molecule_working_dir: ${{ github.repository }}
- if: always()
name: Ensure report file permissions are correct
run: sudo chmod 644 molecule-${{ matrix.scenario }}-report.html
working-directory: ${{ github.repository }}
- if: always()
name: Converts test report
uses: patrick-werner/fhir-html-validation-to-markdown@1.0.0
with:
input_file: ${{ github.repository }}/molecule-${{ matrix.scenario }}-report.html
# Debug with tmate on failure when debug logging is enabled.
- if: ${{ failure() && runner.debug == '1' }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 20
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.html
*.png
.ansible
.cache
__pycache__
7 changes: 7 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# MD013 line-length - Line length
MD013:
line_length: 120
# MD033 no-inline-html - Inline HTML
MD033:
allowed_elements: [details]
9 changes: 9 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
extends: default

ignore: |
.cache
.git

rules:
comments:
min-spaces-from-content: 1
comments-indentation: false
braces:
max-spaces-inside: 1
line-length:
max: 120
level: warning
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
truthy:
ignore: |
?appveyor.yml
Expand Down
16 changes: 16 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
docker = ">=7.1"
pipenv = "*"
molecule = "*"
molecule-docker = "*"
requests = "==2.31.0"

[dev-packages]

[requires]
python_version = "3.10"
Loading